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