Blame SOURCES/libtiff-scanlinesize.patch

0e6869
Partial fix for issues filed upstream at
0e6869
http://bugzilla.maptools.org/show_bug.cgi?id=2140
0e6869
This stops the tiffcmp core dump noted in bug #460322, but isn't enough
0e6869
to make tiffcmp return the right answer (it emits a bunch of error
0e6869
messages instead).
0e6869
0e6869
0e6869
diff -Naur tiff-3.9.2.orig/libtiff/tif_jpeg.c tiff-3.9.2/libtiff/tif_jpeg.c
0e6869
--- tiff-3.9.2.orig/libtiff/tif_jpeg.c	2009-08-30 12:21:46.000000000 -0400
0e6869
+++ tiff-3.9.2/libtiff/tif_jpeg.c	2010-01-05 22:40:40.000000000 -0500
0e6869
@@ -988,8 +988,15 @@
0e6869
 	tsize_t nrows;
0e6869
 	(void) s;
0e6869
 
0e6869
-	/* data is expected to be read in multiples of a scanline */
0e6869
-	if ( (nrows = sp->cinfo.d.image_height) ) {
0e6869
+    nrows = cc / sp->bytesperline;
0e6869
+    if (cc % sp->bytesperline)
0e6869
+		TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline not read");
0e6869
+
0e6869
+    if( nrows > (int) sp->cinfo.d.image_height )
0e6869
+        nrows = sp->cinfo.d.image_height;
0e6869
+
0e6869
+    /* data is expected to be read in multiples of a scanline */
0e6869
+    if (nrows) {
0e6869
 		/* Cb,Cr both have sampling factors 1, so this is correct */
0e6869
 		JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width;            
0e6869
 		int samples_per_clump = sp->samplesperclump;
0e6869
@@ -1087,8 +1094,7 @@
0e6869
 			 * TODO: resolve this */
0e6869
 			buf += sp->bytesperline;
0e6869
 			cc -= sp->bytesperline;
0e6869
-			nrows -= sp->v_sampling;
0e6869
-		} while (nrows > 0);
0e6869
+		} while (--nrows > 0);
0e6869
 
0e6869
 #ifdef JPEG_LIB_MK1
0e6869
 		_TIFFfree(tmpbuf);
0e6869
diff -Naur tiff-3.9.2.orig/libtiff/tif_strip.c tiff-3.9.2/libtiff/tif_strip.c
0e6869
--- tiff-3.9.2.orig/libtiff/tif_strip.c	2006-03-25 13:04:35.000000000 -0500
0e6869
+++ tiff-3.9.2/libtiff/tif_strip.c	2010-01-05 21:39:20.000000000 -0500
0e6869
@@ -238,23 +238,19 @@
0e6869
 				     ycbcrsubsampling + 0,
0e6869
 				     ycbcrsubsampling + 1);
0e6869
 
0e6869
-			if (ycbcrsubsampling[0] == 0) {
0e6869
+			if (ycbcrsubsampling[0]*ycbcrsubsampling[1] == 0) {
0e6869
 				TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
0e6869
 					     "Invalid YCbCr subsampling");
0e6869
 				return 0;
0e6869
 			}
0e6869
 
0e6869
-			scanline = TIFFroundup(td->td_imagewidth,
0e6869
+			/* number of sample clumps per line */
0e6869
+			scanline = TIFFhowmany(td->td_imagewidth,
0e6869
 					       ycbcrsubsampling[0]);
0e6869
-			scanline = TIFFhowmany8(multiply(tif, scanline,
0e6869
-							 td->td_bitspersample,
0e6869
-							 "TIFFScanlineSize"));
0e6869
-			return ((tsize_t)
0e6869
-				summarize(tif, scanline,
0e6869
-					  multiply(tif, 2,
0e6869
-						scanline / ycbcrsubsampling[0],
0e6869
-						"TIFFVStripSize"),
0e6869
-					  "TIFFVStripSize"));
0e6869
+			/* number of samples per line */
0e6869
+			scanline = multiply(tif, scanline,
0e6869
+					    ycbcrsubsampling[0]*ycbcrsubsampling[1] + 2,
0e6869
+					    "TIFFScanlineSize");
0e6869
 		} else {
0e6869
 			scanline = multiply(tif, td->td_imagewidth,
0e6869
 					    td->td_samplesperpixel,