Blame SOURCES/libtiff-tiffinfo-exif.patch

0d8ff3
Teach "tiffinfo -D" to not try to print image data inside an EXIF subdirectory,
0d8ff3
because there isn't any.  Back-patched from an upstream 4.0.2 fix.
0d8ff3
0d8ff3
This is not a security issue in itself (it crashes, but with a simple NULL
0d8ff3
pointer dereference).  However, our test case for CVE-2012-5581 tickles this
0d8ff3
bug, so it seems easier to fix this than make a new test case.
0d8ff3
0d8ff3
0d8ff3
diff -Naur tiff-3.9.4.orig/tools/tiffinfo.c tiff-3.9.4/tools/tiffinfo.c
0d8ff3
--- tiff-3.9.4.orig/tools/tiffinfo.c	2010-06-08 14:50:44.000000000 -0400
0d8ff3
+++ tiff-3.9.4/tools/tiffinfo.c	2012-12-11 16:33:17.062228558 -0500
0d8ff3
@@ -49,7 +49,7 @@
0d8ff3
 int	stoponerr = 1;			/* stop on first read error */
0d8ff3
 
0d8ff3
 static	void usage(void);
0d8ff3
-static	void tiffinfo(TIFF*, uint16, long);
0d8ff3
+static	void tiffinfo(TIFF*, uint16, long, int);
0d8ff3
 
0d8ff3
 int
0d8ff3
 main(int argc, char* argv[])
0d8ff3
@@ -124,19 +124,20 @@
0d8ff3
 		if (tif != NULL) {
0d8ff3
 			if (dirnum != -1) {
0d8ff3
 				if (TIFFSetDirectory(tif, (tdir_t) dirnum))
0d8ff3
-					tiffinfo(tif, order, flags);
0d8ff3
+					tiffinfo(tif, order, flags, 1);
0d8ff3
 			} else if (diroff != 0) {
0d8ff3
 				if (TIFFSetSubDirectory(tif, diroff))
0d8ff3
-					tiffinfo(tif, order, flags);
0d8ff3
+					tiffinfo(tif, order, flags, 1);
0d8ff3
 			} else {
0d8ff3
 				do {
0d8ff3
 					uint32 offset;
0d8ff3
 
0d8ff3
-					tiffinfo(tif, order, flags);
0d8ff3
+					tiffinfo(tif, order, flags, 1);
0d8ff3
 					if (TIFFGetField(tif, TIFFTAG_EXIFIFD,
0d8ff3
 							 &offset)) {
0d8ff3
-						if (TIFFReadEXIFDirectory(tif, offset))
0d8ff3
-							tiffinfo(tif, order, flags);
0d8ff3
+						if (TIFFReadEXIFDirectory(tif, offset)) {
0d8ff3
+							tiffinfo(tif, order, flags, 0);
0d8ff3
+						}
0d8ff3
 					}
0d8ff3
 				} while (TIFFReadDirectory(tif));
0d8ff3
 			}
0d8ff3
@@ -426,10 +427,10 @@
0d8ff3
 }
0d8ff3
 
0d8ff3
 static void
0d8ff3
-tiffinfo(TIFF* tif, uint16 order, long flags)
0d8ff3
+tiffinfo(TIFF* tif, uint16 order, long flags, int is_image)
0d8ff3
 {
0d8ff3
 	TIFFPrintDirectory(tif, stdout, flags);
0d8ff3
-	if (!readdata)
0d8ff3
+	if (!readdata || !is_image)
0d8ff3
 		return;
0d8ff3
 	if (rawdata) {
0d8ff3
 		if (order) {