1 commit 6d3ef98b2415b2edfa36a5ba600d5a824c094309
2 Author: erouault <erouault>
3 Date: Sat Dec 3 14:42:40 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=2597
10 diff --git a/ChangeLog b/ChangeLog
11 index e41d00c..0d7b12d 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=2597
22 +2016-12-03 Even Rouault <even.rouault at spatialys.com>
24 * tools/tiffinfo.c: fix null pointer dereference in -r mode when the image has
25 no StripByteCount tag.
26 Reported by Agostino Sarubbo.
27 diff --git a/tools/tiffcp.c b/tools/tiffcp.c
28 index 6dfb9a9..c8e48c3 100644
32 -/* $Id: tiffcp.c,v 1.56 2016-12-02 22:13:32 erouault Exp $ */
33 +/* $Id: tiffcp.c,v 1.57 2016-12-03 14:42:40 erouault Exp $ */
36 * Copyright (c) 1988-1997 Sam Leffler
37 @@ -1378,7 +1378,7 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
38 uint8* bufp = (uint8*) buf;
41 - uint16 bps, bytes_per_sample;
42 + uint16 bps = 0, bytes_per_sample;
44 tilebuf = _TIFFmalloc(tilesize);
46 @@ -1387,6 +1387,12 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
47 (void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw);
48 (void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl);
49 (void) TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps);
52 + TIFFError(TIFFFileName(in), "Error, cannot read BitsPerSample");
56 assert( bps % 8 == 0 );
57 bytes_per_sample = bps/8;