8ca2e9
Upstream fix for bug #603024 is incomplete, tif_ojpeg.c should guard against
8ca2e9
missing strip byte counts too.  Testing shows that tiffsplit.c has an issue
8ca2e9
too.
8ca2e9
8ca2e9
Filed upstream at http://bugzilla.maptools.org/show_bug.cgi?id=1996
8ca2e9
8ca2e9
8ca2e9
diff -Naur tiff-3.9.4.orig/libtiff/tif_ojpeg.c tiff-3.9.4/libtiff/tif_ojpeg.c
8ca2e9
--- tiff-3.9.4.orig/libtiff/tif_ojpeg.c	2010-06-08 19:29:51.000000000 -0400
8ca2e9
+++ tiff-3.9.4/libtiff/tif_ojpeg.c	2010-06-22 11:25:17.579807706 -0400
8ca2e9
@@ -1920,6 +1920,10 @@
8ca2e9
 							sp->in_buffer_file_pos=0;
8ca2e9
 						else
8ca2e9
 						{
8ca2e9
+							if (sp->tif->tif_dir.td_stripbytecount == 0) {
8ca2e9
+								TIFFErrorExt(sp->tif->tif_clientdata,sp->tif->tif_name,"Strip byte counts are missing");
8ca2e9
+								return(0);
8ca2e9
+							}
8ca2e9
 							sp->in_buffer_file_togo=sp->tif->tif_dir.td_stripbytecount[sp->in_buffer_next_strile];  
8ca2e9
 							if (sp->in_buffer_file_togo==0)
8ca2e9
 								sp->in_buffer_file_pos=0;
8ca2e9
diff -Naur tiff-3.9.4.orig/tools/tiffsplit.c tiff-3.9.4/tools/tiffsplit.c
8ca2e9
--- tiff-3.9.4.orig/tools/tiffsplit.c	2010-06-08 14:50:44.000000000 -0400
8ca2e9
+++ tiff-3.9.4/tools/tiffsplit.c	2010-06-22 12:23:23.258823151 -0400
8ca2e9
@@ -237,7 +237,10 @@
8ca2e9
 		tstrip_t s, ns = TIFFNumberOfStrips(in);
8ca2e9
 		uint32 *bytecounts;
8ca2e9
 
8ca2e9
-		TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts);
8ca2e9
+		if (!TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts)) {
8ca2e9
+			fprintf(stderr, "tiffsplit: strip byte counts are missing\n");
8ca2e9
+			return (0);
8ca2e9
+		}
8ca2e9
 		for (s = 0; s < ns; s++) {
8ca2e9
 			if (bytecounts[s] > (uint32)bufsize) {
8ca2e9
 				buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[s]);
8ca2e9
@@ -267,7 +270,10 @@
8ca2e9
 		ttile_t t, nt = TIFFNumberOfTiles(in);
8ca2e9
 		uint32 *bytecounts;
8ca2e9
 
8ca2e9
-		TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts);
8ca2e9
+		if (!TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts)) {
8ca2e9
+			fprintf(stderr, "tiffsplit: tile byte counts are missing\n");
8ca2e9
+			return (0);
8ca2e9
+		}
8ca2e9
 		for (t = 0; t < nt; t++) {
8ca2e9
 			if (bytecounts[t] > (uint32) bufsize) {
8ca2e9
 				buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[t]);