From 101253c74cde97203dab28c4f3bd0994cea5804c Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 14 Jan 2017 13:12:33 +0000 Subject: [PATCH] * tools/raw2tiff.c: avoid integer division by zero. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2631 --- ChangeLog | 5 +++++ tools/raw2tiff.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/raw2tiff.c b/tools/raw2tiff.c index 7298e80a95c9..083e9ee73f0f 100644 --- a/tools/raw2tiff.c +++ b/tools/raw2tiff.c @@ -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) { -- 2.12.0