Fax3SetupState(): check consistency of rowbytes and rowpixels

also add some parameter documentation to Fax3Decode1D()

fixes #160
http://bugzilla.maptools.org/show_bug.cgi?id=2854
This commit is contained in:
Thomas Bernard 2020-03-11 23:34:21 +01:00
parent 8614c4046f
commit 197bfe4c14
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C

View File

@ -219,8 +219,12 @@ Fax3PrematureEOF(const char* module, TIFF* tif, uint32 line, uint32 a0)
#define Nop
/*
/**
* Decode the requested amount of G3 1D-encoded data.
* @param buf destination buffer
* @param occ available bytes in destination buffer
* @param s number of planes (ignored)
* @returns 1 for success, -1 in case of error
*/
static int
Fax3Decode1D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
@ -524,6 +528,13 @@ Fax3SetupState(TIFF* tif)
rowbytes = TIFFScanlineSize(tif);
rowpixels = td->td_imagewidth;
}
if (rowbytes < (rowpixels + 7) / 8)
{
TIFFErrorExt(tif->tif_clientdata, module,
"Inconsistent number of bytes per row : rowbytes=%lu rowpixels=%lu",
(unsigned long)(rowbytes), (unsigned long)(rowpixels));
return (0);
}
sp->rowbytes = rowbytes;
sp->rowpixels = rowpixels;
/*