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:
parent
ede67090cb
commit
2fdab9ba70
@ -481,6 +481,17 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load )
|
|||||||
pdf->pages[i].height = VIPS_RINT(
|
pdf->pages[i].height = VIPS_RINT(
|
||||||
FPDF_GetPageHeight( pdf->page ) * pdf->scale );
|
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 )
|
if( pdf->pages[i].width > pdf->image.width )
|
||||||
pdf->image.width = pdf->pages[i].width;
|
pdf->image.width = pdf->pages[i].width;
|
||||||
pdf->image.height += pdf->pages[i].height;
|
pdf->image.height += pdf->pages[i].height;
|
||||||
|
Loading…
Reference in New Issue
Block a user