* tools/tiffcp.c: avoid potential division by zero is BitsPerSamples tag is

missing.
Reported by Agostino sarubbo.
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2597
This commit is contained in:
Even Rouault 2016-12-03 14:42:40 +00:00
parent 2deb7183ca
commit 5b52559d39
2 changed files with 15 additions and 2 deletions

View File

@ -1,3 +1,10 @@
2016-12-03 Even Rouault <even.rouault at spatialys.com>
* tools/tiffcp.c: avoid potential division by zero is BitsPerSamples tag is
missing.
Reported by Agostino sarubbo.
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2597
2016-12-03 Even Rouault <even.rouault at spatialys.com>
* tools/tiffinfo.c: fix null pointer dereference in -r mode when the image has

View File

@ -1,4 +1,4 @@
/* $Id: tiffcp.c,v 1.56 2016-12-02 22:13:32 erouault Exp $ */
/* $Id: tiffcp.c,v 1.57 2016-12-03 14:42:40 erouault Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -1378,7 +1378,7 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
uint8* bufp = (uint8*) buf;
uint32 tw, tl;
uint32 row;
uint16 bps, bytes_per_sample;
uint16 bps = 0, bytes_per_sample;
tilebuf = _TIFFmalloc(tilesize);
if (tilebuf == 0)
@ -1387,6 +1387,12 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
(void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw);
(void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl);
(void) TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps);
if( bps == 0 )
{
TIFFError(TIFFFileName(in), "Error, cannot read BitsPerSample");
status = 0;
goto done;
}
assert( bps % 8 == 0 );
bytes_per_sample = bps/8;