aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-multimedia/libtiff/files/CVE-2017-7598.patch
blob: 6d082bb613d92dd143aba482f88e840d135593d3 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From 3cfd62d77c2a7e147a05bd678524c345fa9c2bb8 Mon Sep 17 00:00:00 2001
From: erouault <erouault>
Date: Wed, 11 Jan 2017 13:28:01 +0000
Subject: [PATCH] * libtiff/tif_dirread.c: avoid division by floating point 0
 in TIFFReadDirEntryCheckedRational() and TIFFReadDirEntryCheckedSrational(),
 and return 0 in that case (instead of infinity as before presumably)
 Apparently some sanitizers do not like those divisions by zero. Fixes
 http://bugzilla.maptools.org/show_bug.cgi?id=2644

Upstream-Status: Backport

CVE: CVE-2017-7598
Signed-off-by: Rajkumar Veer <rveer@mvista.com>
Index: tiff-4.0.7/ChangeLog
===================================================================
--- tiff-4.0.7.orig/ChangeLog	2017-04-25 16:14:59.858612730 +0530
+++ tiff-4.0.7/ChangeLog	2017-04-25 18:11:36.048107127 +0530
@@ -1,3 +1,4 @@
+
 2017-01-12 Even Rouault <even.rouault at spatialys.com>
 
 	* libtiff/tif_ojpeg.c: fix leak in OJPEGReadHeaderInfoSecTablesQTable,
@@ -8,6 +9,14 @@
 
 2017-01-11 Even Rouault <even.rouault at spatialys.com>
 
+	* libtiff/tif_dirread.c: avoid division by floating point 0 in
+	TIFFReadDirEntryCheckedRational() and TIFFReadDirEntryCheckedSrational(),
+	and return 0 in that case (instead of infinity as before presumably)
+	Apparently some sanitizers do not like those divisions by zero.
+	Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2644
+
+2017-01-11 Even Rouault <even.rouault at spatialys.com>
+
 	* libtiff/tif_dir.c, tif_dirread.c, tif_dirwrite.c: implement various clampings
 	of double to other data types to avoid undefined behaviour if the output range
 	isn't big enough to hold the input value.
Index: tiff-4.0.7/libtiff/tif_dirread.c
===================================================================
--- tiff-4.0.7.orig/libtiff/tif_dirread.c	2017-04-25 16:14:59.858612730 +0530
+++ tiff-4.0.7/libtiff/tif_dirread.c	2017-04-25 18:16:21.836111576 +0530
@@ -2880,7 +2880,10 @@
 		m.l = direntry->tdir_offset.toff_long8;
 	if (tif->tif_flags&TIFF_SWAB)
 		TIFFSwabArrayOfLong(m.i,2);
-	if (m.i[0]==0)
+        /* Not completely sure what we should do when m.i[1]==0, but some */
+        /* sanitizers do not like division by 0.0: */
+        /* http://bugzilla.maptools.org/show_bug.cgi?id=2644 */
+	if (m.i[0]==0 || m.i[1]==0)
 		*value=0.0;
 	else
 		*value=(double)m.i[0]/(double)m.i[1];
@@ -2908,7 +2911,10 @@
 		m.l=direntry->tdir_offset.toff_long8;
 	if (tif->tif_flags&TIFF_SWAB)
 		TIFFSwabArrayOfLong(m.i,2);
-	if ((int32)m.i[0]==0)
+        /* Not completely sure what we should do when m.i[1]==0, but some */
+        /* sanitizers do not like division by 0.0: */
+        /* http://bugzilla.maptools.org/show_bug.cgi?id=2644 */
+	if ((int32)m.i[0]==0 || m.i[1]==0)
 		*value=0.0;
 	else
 		*value=(double)((int32)m.i[0])/(double)m.i[1];