* 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=2607
This commit is contained in:
Even Rouault 2016-12-03 15:44:15 +00:00
parent f703a4c7b3
commit b1e5ae5984
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=2607
2016-12-03 Even Rouault <even.rouault at spatialys.com>
* man/Makefile.am: remove thumbnail.1 and rgb2ycbcr.1 from installed man

View File

@ -1,4 +1,4 @@
/* $Id: tiffcp.c,v 1.57 2016-12-03 14:42:40 erouault Exp $ */
/* $Id: tiffcp.c,v 1.58 2016-12-03 15:44:15 erouault Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -1569,7 +1569,7 @@ DECLAREwriteFunc(writeBufferToSeparateTiles)
uint8* bufp = (uint8*) buf;
uint32 tl, tw;
uint32 row;
uint16 bps, bytes_per_sample;
uint16 bps = 0, bytes_per_sample;
obuf = _TIFFmalloc(TIFFTileSize(out));
if (obuf == NULL)
@ -1578,6 +1578,12 @@ DECLAREwriteFunc(writeBufferToSeparateTiles)
(void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl);
(void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw);
(void) TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps);
if( bps == 0 )
{
TIFFError(TIFFFileName(out), "Error, cannot read BitsPerSample");
_TIFFfree(obuf);
return 0;
}
assert( bps % 8 == 0 );
bytes_per_sample = bps/8;