Blame SOURCES/libtiff-checkbytecount.patch

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