check page size from pdfium

PDFium allows page width and height to be less than 1, which will cause
libvips severe indegestion.
This commit is contained in:
John Cupitt 2022-03-08 10:21:08 +00:00
parent ede67090cb
commit 2fdab9ba70
1 changed files with 11 additions and 0 deletions

View File

@ -481,6 +481,17 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load )
pdf->pages[i].height = VIPS_RINT(
FPDF_GetPageHeight( pdf->page ) * pdf->scale );
/* PDFium allows page width or height to be less than 1 (!!).
*/
if( pdf->pages[i].width < 1 ||
pdf->pages[i].height < 1 ||
pdf->pages[i].width > VIPS_MAX_COORD ||
pdf->pages[i].height > VIPS_MAX_COORD ) {
vips_error( class->nickname,
"%s", _( "page size out of range" ) );
return( -1 );
}
if( pdf->pages[i].width > pdf->image.width )
pdf->image.width = pdf->pages[i].width;
pdf->image.height += pdf->pages[i].height;