Blame SOURCES/libtiff-tiffinfo-exif.patch

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