summaryrefslogtreecommitdiffstats
path: root/meta/recipes-multimedia/libtiff/files/CVE-2023-40745.patch
blob: 6eb286039f93bbc416cf19b07bff2b633ec9563d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From 4fc16f649fa2875d5c388cf2edc295510a247ee5 Mon Sep 17 00:00:00 2001
From: Arie Haenel <arie.haenel@jct.ac.il>
Date: Wed, 19 Jul 2023 19:34:25 +0000
Subject: [PATCH] tiffcp: fix memory corruption (overflow) on hostile images
 (fixes #591)

Upstream-Status: Backport from [https://gitlab.com/libtiff/libtiff/-/commit/4fc16f649fa2875d5c388cf2edc295510a247ee5]
CVE: CVE-2023-40745
Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
---
 tools/tiffcp.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/tiffcp.c b/tools/tiffcp.c
index 83b3910..007bd05 100644
--- a/tools/tiffcp.c
+++ b/tools/tiffcp.c
@@ -1437,6 +1437,13 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
 		TIFFError(TIFFFileName(in), "Error, cannot handle that much samples per tile row (Tile Width * Samples/Pixel)");
 		return 0;
 	}
+
+	if ( (imagew - tilew * spp) > INT_MAX ){
+        TIFFError(TIFFFileName(in),
+                  "Error, image raster scan line size is too large");
+        return 0;
+	}
+
 	iskew = imagew - tilew*spp;
 	tilebuf = _TIFFmalloc(tilesize);
 	if (tilebuf == 0)
-- 
2.25.1