1 commit 307a31765cb01245e3655ce168385dd7d51e14bd
2 Author: erouault <erouault>
3 Date: Sat Dec 3 15:44:15 2016 +0000
5 * tools/tiffcp.c: avoid potential division by zero if BitsPerSamples tag is
7 Reported by Agostino Sarubbo.
8 Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2607
10 diff --git a/ChangeLog b/ChangeLog
11 index ac2d922..94be038 100644
15 2016-12-03 Even Rouault <even.rouault at spatialys.com>
17 + * tools/tiffcp.c: avoid potential division by zero if BitsPerSamples tag is
19 + Reported by Agostino Sarubbo.
20 + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2607
22 +2016-12-03 Even Rouault <even.rouault at spatialys.com>
24 * tools/tif_dir.c: when TIFFGetField(, TIFFTAG_NUMBEROFINKS, ) is called,
25 limit the return number of inks to SamplesPerPixel, so that code that parses
26 ink names doesn't go past the end of the buffer.
27 diff --git a/tools/tiffcp.c b/tools/tiffcp.c
28 index c8e48c3..142cbb0 100644
32 -/* $Id: tiffcp.c,v 1.57 2016-12-03 14:42:40 erouault Exp $ */
33 +/* $Id: tiffcp.c,v 1.58 2016-12-03 15:44:15 erouault Exp $ */
36 * Copyright (c) 1988-1997 Sam Leffler
37 @@ -1569,7 +1569,7 @@ DECLAREwriteFunc(writeBufferToSeparateTiles)
38 uint8* bufp = (uint8*) buf;
41 - uint16 bps, bytes_per_sample;
42 + uint16 bps = 0, bytes_per_sample;
44 obuf = _TIFFmalloc(TIFFTileSize(out));
46 @@ -1578,6 +1578,12 @@ DECLAREwriteFunc(writeBufferToSeparateTiles)
47 (void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl);
48 (void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw);
49 (void) TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps);
52 + TIFFError(TIFFFileName(out), "Error, cannot read BitsPerSample");
56 assert( bps % 8 == 0 );
57 bytes_per_sample = bps/8;