Blame SOURCES/libtiff-printdir-width.patch

e4d7d2
Make TIFFPrintDirectory cope with both TIFF_VARIABLE and TIFF_VARIABLE2
e4d7d2
conventions for field_passcount fields, ie, either 16- or 32-bit counts.
e4d7d2
This patch is taken from upstream commits dated 2012-05-23 ("fix crash
e4d7d2
with odd 16bit count types for some custom fields") and 2012-12-12 ("Fix
e4d7d2
TIFF_VARIABLE/TIFF_VARIABLE2 confusion in TIFFPrintDirectory").
e4d7d2
e4d7d2
This doesn't qualify as a security issue in itself, mainly because
e4d7d2
TIFFPrintDirectory is unlikely to be used in any security-exposed
e4d7d2
scenarios; but we need to fix it so that our test case for CVE-2012-5581
e4d7d2
works on all platforms.
e4d7d2
e4d7d2
e4d7d2
diff -Naur tiff-3.9.4.orig/libtiff/tif_print.c tiff-3.9.4/libtiff/tif_print.c
e4d7d2
--- tiff-3.9.4.orig/libtiff/tif_print.c	2010-06-08 14:50:42.000000000 -0400
e4d7d2
+++ tiff-3.9.4/libtiff/tif_print.c	2012-12-13 12:17:33.726765771 -0500
e4d7d2
@@ -518,8 +518,19 @@
e4d7d2
 			continue;
e4d7d2
 
e4d7d2
 		if(fip->field_passcount) {
e4d7d2
-			if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
e4d7d2
+			if (fip->field_readcount == TIFF_VARIABLE2 ) {
e4d7d2
+				if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
e4d7d2
+					continue;
e4d7d2
+			} else if (fip->field_readcount == TIFF_VARIABLE ) {
e4d7d2
+				uint16 small_value_count;
e4d7d2
+				if(TIFFGetField(tif, tag, &small_value_count, &raw_data) != 1)
e4d7d2
+					continue;
e4d7d2
+				value_count = small_value_count;
e4d7d2
+			} else {
e4d7d2
+				assert (fip->field_readcount == TIFF_VARIABLE
e4d7d2
+					|| fip->field_readcount == TIFF_VARIABLE2);
e4d7d2
 				continue;
e4d7d2
+			} 
e4d7d2
 		} else {
e4d7d2
 			if (fip->field_readcount == TIFF_VARIABLE
e4d7d2
 			    || fip->field_readcount == TIFF_VARIABLE2)