6456d8
Make tiffdump more paranoid about checking the count field of a directory
6456d8
entry.
6456d8
6456d8
Filed upstream at http://bugzilla.maptools.org/show_bug.cgi?id=2218
6456d8
6456d8
6456d8
diff -Naur tiff-3.9.4.orig/tools/tiffdump.c tiff-3.9.4/tools/tiffdump.c
6456d8
--- tiff-3.9.4.orig/tools/tiffdump.c	2010-06-08 14:50:44.000000000 -0400
6456d8
+++ tiff-3.9.4/tools/tiffdump.c	2010-06-22 12:51:42.207932477 -0400
6456d8
@@ -46,6 +46,7 @@
6456d8
 # include <io.h>
6456d8
 #endif
6456d8
 
6456d8
+#include "tiffiop.h"
6456d8
 #include "tiffio.h"
6456d8
 
6456d8
 #ifndef O_BINARY
6456d8
@@ -317,7 +318,7 @@
6456d8
 			printf(">\n");
6456d8
 			continue;
6456d8
 		}
6456d8
-		space = dp->tdir_count * datawidth[dp->tdir_type];
6456d8
+		space = TIFFSafeMultiply(int, dp->tdir_count, datawidth[dp->tdir_type]);
6456d8
 		if (space <= 0) {
6456d8
 			printf(">\n");
6456d8
 			Error("Invalid count for tag %u", dp->tdir_tag);
6456d8
@@ -709,7 +710,7 @@
6456d8
 	w = (dir->tdir_type < NWIDTHS ? datawidth[dir->tdir_type] : 0);
6456d8
 	cc = dir->tdir_count * w;
6456d8
 	if (lseek(fd, (off_t)dir->tdir_offset, 0) != (off_t)-1
6456d8
-	    && read(fd, cp, cc) != -1) {
6456d8
+	    && read(fd, cp, cc) == cc) {
6456d8
 		if (swabflag) {
6456d8
 			switch (dir->tdir_type) {
6456d8
 			case TIFF_SHORT: