summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorerouault <erouault>2017-01-14 13:12:33 +0000
committererouault <erouault>2017-01-14 13:12:33 +0000
commit7ae18cf04df0af8794e7d9431ace7cd74f297f61 (patch)
tree9852e1ca97c8ab22b6c87c588d0d2fadae30761b /tools
parentc8b7f53f523445c70bc8810698367444934cf89b (diff)
downloadlibtiff-7ae18cf04df0af8794e7d9431ace7cd74f297f61.tar.gz
* tools/raw2tiff.c: avoid integer division by zero.
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2631
Diffstat (limited to 'tools')
-rw-r--r--tools/raw2tiff.c10
1 files changed, 8 insertions, 2 deletions
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) {