* tools/tiffcrop.c: add 3 extra bytes at end of strip buffer in
readSeparateStripsIntoBuffer() to avoid read outside of heap allocated buffer. Reported by Agostina Sarubo. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2621
This commit is contained in:
parent
3a1c5ac67b
commit
7aad042fc8
@ -1,3 +1,10 @@
|
|||||||
|
2016-12-03 Even Rouault <even.rouault at spatialys.com>
|
||||||
|
|
||||||
|
* tools/tiffcrop.c: add 3 extra bytes at end of strip buffer in
|
||||||
|
readSeparateStripsIntoBuffer() to avoid read outside of heap allocated buffer.
|
||||||
|
Reported by Agostina Sarubo.
|
||||||
|
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2621
|
||||||
|
|
||||||
2016-12-03 Even Rouault <even.rouault at spatialys.com>
|
2016-12-03 Even Rouault <even.rouault at spatialys.com>
|
||||||
|
|
||||||
* tools/tiffcrop.c: fix readContigStripsIntoBuffer() in -i (ignore) mode so
|
* tools/tiffcrop.c: fix readContigStripsIntoBuffer() in -i (ignore) mode so
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tiffcrop.c,v 1.47 2016-12-03 11:35:56 erouault Exp $ */
|
/* $Id: tiffcrop.c,v 1.48 2016-12-03 12:19:32 erouault Exp $ */
|
||||||
|
|
||||||
/* tiffcrop.c -- a port of tiffcp.c extended to include manipulations of
|
/* tiffcrop.c -- a port of tiffcp.c extended to include manipulations of
|
||||||
* the image data through additional options listed below
|
* the image data through additional options listed below
|
||||||
@ -4815,10 +4815,17 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8 *obuf, uint32 length,
|
|||||||
nstrips = TIFFNumberOfStrips(in);
|
nstrips = TIFFNumberOfStrips(in);
|
||||||
strips_per_sample = nstrips /spp;
|
strips_per_sample = nstrips /spp;
|
||||||
|
|
||||||
|
/* Add 3 padding bytes for combineSeparateSamples32bits */
|
||||||
|
if( (size_t) stripsize > 0xFFFFFFFFU - 3U )
|
||||||
|
{
|
||||||
|
TIFFError("readSeparateStripsIntoBuffer", "Integer overflow when calculating buffer size.");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++)
|
for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++)
|
||||||
{
|
{
|
||||||
srcbuffs[s] = NULL;
|
srcbuffs[s] = NULL;
|
||||||
buff = _TIFFmalloc(stripsize);
|
buff = _TIFFmalloc(stripsize + 3);
|
||||||
if (!buff)
|
if (!buff)
|
||||||
{
|
{
|
||||||
TIFFError ("readSeparateStripsIntoBuffer",
|
TIFFError ("readSeparateStripsIntoBuffer",
|
||||||
@ -4827,6 +4834,9 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8 *obuf, uint32 length,
|
|||||||
_TIFFfree (srcbuffs[i]);
|
_TIFFfree (srcbuffs[i]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
buff[stripsize] = 0;
|
||||||
|
buff[stripsize+1] = 0;
|
||||||
|
buff[stripsize+2] = 0;
|
||||||
srcbuffs[s] = buff;
|
srcbuffs[s] = buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user