70f9f0
From aa6829cda019f56ed882b2db2d1e84c994412f9d Mon Sep 17 00:00:00 2001
70f9f0
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
70f9f0
Date: Wed, 11 Jan 2017 12:58:22 +0100
70f9f0
Subject: [PATCH 3/5] Fix CVE-2016-9540
70f9f0
70f9f0
---
70f9f0
 tools/tiffcp.c | 4 ++--
70f9f0
 1 file changed, 2 insertions(+), 2 deletions(-)
70f9f0
70f9f0
diff --git a/tools/tiffcp.c b/tools/tiffcp.c
70f9f0
index 8c696db..2903461 100644
70f9f0
--- a/tools/tiffcp.c
70f9f0
+++ b/tools/tiffcp.c
70f9f0
@@ -1330,7 +1330,7 @@ DECLAREreadFunc(readContigTilesIntoBuffer)
70f9f0
 		uint32 colb = 0;
70f9f0
 		uint32 col;
70f9f0
 
70f9f0
-		for (col = 0; col < imagewidth; col += tw) {
70f9f0
+		for (col = 0; col < imagewidth && colb < imagew; col += tw) {
70f9f0
 			if (TIFFReadTile(in, tilebuf, col, row, 0, 0) < 0
70f9f0
 			    && !ignore) {
70f9f0
 				TIFFError(TIFFFileName(in),
70f9f0
@@ -1515,7 +1515,7 @@ DECLAREwriteFunc(writeBufferToContigTiles)
70f9f0
 		uint32 colb = 0;
70f9f0
 		uint32 col;
70f9f0
 
70f9f0
-		for (col = 0; col < imagewidth; col += tw) {
70f9f0
+		for (col = 0; col < imagewidth && colb < imagew; col += tw) {
70f9f0
 			/*
70f9f0
 			 * Tile is clipped horizontally.  Calculate
70f9f0
 			 * visible portion and skewing factors.
70f9f0
-- 
70f9f0
2.7.4
70f9f0