summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--tools/raw2tiff.c10
2 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index cd2fa171..ee7c7f56 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* libtiff/tif_ojpeg.c: fix leak in OJPEGReadHeaderInfoSecTablesQTable,
diff --git a/tools/raw2tiff.c b/tools/raw2tiff.c
index 7298e80a..083e9ee7 100644
--- a/tools/raw2tiff.c
+++ b/tools/raw2tiff.c
@@ -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
* 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) {
unsigned int fail = 0;
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++) {
if (imagesize % w == 0) {