Blame SOURCES/0007-CVE-2017-18013-libtiff-tif_print.c-TIFFPrintDirector.patch

ccba1e
From 4d6c37328f38636d5002a6f1b584ad8e6031c61c Mon Sep 17 00:00:00 2001
b03815
From: Even Rouault <even.rouault@spatialys.com>
b03815
Date: Sun, 31 Dec 2017 15:09:41 +0100
ccba1e
Subject: [PATCH] (CVE-2017-18013) libtiff/tif_print.c: TIFFPrintDirectory():
ccba1e
 fix null pointer dereference on corrupted file. Fixes
ccba1e
 http://bugzilla.maptools.org/show_bug.cgi?id=2770
b03815
ccba1e
(cherry picked from commit c6f41df7b581402dfba3c19a1e3df4454c551a01)
b03815
---
b03815
 libtiff/tif_print.c | 8 ++++----
b03815
 1 file changed, 4 insertions(+), 4 deletions(-)
b03815
b03815
diff --git a/libtiff/tif_print.c b/libtiff/tif_print.c
ccba1e
index 10a588ea..b9b53a0f 100644
b03815
--- a/libtiff/tif_print.c
b03815
+++ b/libtiff/tif_print.c
b03815
@@ -667,13 +667,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
b03815
 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
b03815
 			fprintf(fd, "    %3lu: [%8I64u, %8I64u]\n",
b03815
 			    (unsigned long) s,
b03815
-			    (unsigned __int64) td->td_stripoffset[s],
b03815
-			    (unsigned __int64) td->td_stripbytecount[s]);
b03815
+			    td->td_stripoffset ? (unsigned __int64) td->td_stripoffset[s] : 0,
b03815
+			    td->td_stripbytecount ? (unsigned __int64) td->td_stripbytecount[s] : 0);
b03815
 #else
b03815
 			fprintf(fd, "    %3lu: [%8llu, %8llu]\n",
b03815
 			    (unsigned long) s,
b03815
-			    (unsigned long long) td->td_stripoffset[s],
b03815
-			    (unsigned long long) td->td_stripbytecount[s]);
b03815
+			    td->td_stripoffset ? (unsigned long long) td->td_stripoffset[s] : 0,
b03815
+			    td->td_stripbytecount ? (unsigned long long) td->td_stripbytecount[s] : 0);
b03815
 #endif
b03815
 	}
b03815
 }