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