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