* tools/raw2tiff.c: avoid integer division by zero.

Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2631
This commit is contained in:
Even Rouault 2017-01-14 13:12:33 +00:00
parent ab7f27a984
commit 55e5962794
2 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2017-01-14 Even Rouault <even.rouault at spatialys.com>
* tools/raw2tiff.c: avoid integer division by zero.
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2631
2017-01-12 Even Rouault <even.rouault at spatialys.com> 2017-01-12 Even Rouault <even.rouault at spatialys.com>
* libtiff/tif_ojpeg.c: fix leak in OJPEGReadHeaderInfoSecTablesQTable, * libtiff/tif_ojpeg.c: fix leak in OJPEGReadHeaderInfoSecTablesQTable,

View File

@ -1,4 +1,4 @@
/* $Id: raw2tiff.c,v 1.28 2015-08-19 02:31:04 bfriesen Exp $ /* $Id: raw2tiff.c,v 1.29 2017-01-14 13:12:33 erouault Exp $
* *
* Project: libtiff tools * Project: libtiff tools
* Purpose: Convert raw byte sequences in TIFF images * Purpose: Convert raw byte sequences in TIFF images
@ -408,8 +408,14 @@ guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, uint32 nbands,
} else if (*width == 0 && *length == 0) { } else if (*width == 0 && *length == 0) {
unsigned int fail = 0; unsigned int fail = 0;
fprintf(stderr, "Image width and height are not specified.\n"); fprintf(stderr, "Image width and height are not specified.\n");
w = (uint32) sqrt(imagesize / longt);
if( w == 0 )
{
fprintf(stderr, "Too small image size.\n");
return -1;
}
for (w = (uint32) sqrt(imagesize / longt); for (;
w < sqrt(imagesize * longt); w < sqrt(imagesize * longt);
w++) { w++) {
if (imagesize % w == 0) { if (imagesize % w == 0) {