Blame SOURCES/libtiff-CVE-2016-5652.patch

70f9f0
From bb2505b3d099104a296823fc3a456680417475b0 Mon Sep 17 00:00:00 2001
70f9f0
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
70f9f0
Date: Thu, 12 Jan 2017 11:30:40 +0100
70f9f0
Subject: [PATCH 4/5] Fix CVE-2016-5652
70f9f0
70f9f0
---
70f9f0
 tools/tiff2pdf.c | 17 ++++++++++-------
70f9f0
 1 file changed, 10 insertions(+), 7 deletions(-)
70f9f0
70f9f0
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
70f9f0
index fbca305..9df5b16 100644
70f9f0
--- a/tools/tiff2pdf.c
70f9f0
+++ b/tools/tiff2pdf.c
70f9f0
@@ -2826,21 +2826,24 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_
70f9f0
 				return(0);
70f9f0
 			}
70f9f0
 			if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0) {
70f9f0
-				if (count > 0) {
70f9f0
-					_TIFFmemcpy(buffer, jpt, count);
70f9f0
+				if (count >= 4) {
70f9f0
+                    /* Ignore EOI marker of JpegTables */
70f9f0
+					_TIFFmemcpy(buffer, jpt, count - 2);
70f9f0
 					bufferoffset += count - 2;
70f9f0
+                    /* Store last 2 bytes of the JpegTables */
70f9f0
 					table_end[0] = buffer[bufferoffset-2];
70f9f0
 					table_end[1] = buffer[bufferoffset-1];
70f9f0
-				}
70f9f0
-				if (count > 0) {
70f9f0
 					xuint32 = bufferoffset;
70f9f0
+                    bufferoffset -= 2;
70f9f0
 					bufferoffset += TIFFReadRawTile(
70f9f0
 						input, 
70f9f0
 						tile, 
70f9f0
-						(tdata_t) &(((unsigned char*)buffer)[bufferoffset-2]), 
70f9f0
+						(tdata_t) &(((unsigned char*)buffer)[bufferoffset]), 
70f9f0
 						-1);
70f9f0
-						buffer[xuint32-2]=table_end[0];
70f9f0
-						buffer[xuint32-1]=table_end[1];
70f9f0
+                    /* Overwrite SOI marker of image scan with previously */
70f9f0
+                    /* saved end of JpegTables */
70f9f0
+					buffer[xuint32-2]=table_end[0];
70f9f0
+					buffer[xuint32-1]=table_end[1];
70f9f0
 				} else {
70f9f0
 					bufferoffset += TIFFReadRawTile(
70f9f0
 						input, 
70f9f0
-- 
70f9f0
2.7.4
70f9f0