Merge pull request #4451 from ianchi/youtube-dl
[feed/packages.git] / libs / tiff / patches / 118-CVE-2017-7598.patch
1 From 3cfd62d77c2a7e147a05bd678524c345fa9c2bb8 Mon Sep 17 00:00:00 2001
2 From: erouault <erouault>
3 Date: Wed, 11 Jan 2017 13:28:01 +0000
4 Subject: [PATCH] * libtiff/tif_dirread.c: avoid division by floating point 0
5 in TIFFReadDirEntryCheckedRational() and TIFFReadDirEntryCheckedSrational(),
6 and return 0 in that case (instead of infinity as before presumably)
7 Apparently some sanitizers do not like those divisions by zero. Fixes
8 http://bugzilla.maptools.org/show_bug.cgi?id=2644
9
10 ---
11 ChangeLog | 8 ++++++++
12 libtiff/tif_dirread.c | 10 ++++++++--
13 2 files changed, 16 insertions(+), 2 deletions(-)
14
15 diff --git a/ChangeLog b/ChangeLog
16 index 6a752cd..722a405 100644
17 --- a/ChangeLog
18 +++ b/ChangeLog
19 @@ -1,5 +1,13 @@
20 2017-01-11 Even Rouault <even.rouault at spatialys.com>
21
22 + * libtiff/tif_dirread.c: avoid division by floating point 0 in
23 + TIFFReadDirEntryCheckedRational() and TIFFReadDirEntryCheckedSrational(),
24 + and return 0 in that case (instead of infinity as before presumably)
25 + Apparently some sanitizers do not like those divisions by zero.
26 + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2644
27 +
28 +2017-01-11 Even Rouault <even.rouault at spatialys.com>
29 +
30 * libtiff/tif_jpeg.c: avoid integer division by zero in
31 JPEGSetupEncode() when horizontal or vertical sampling is set to 0.
32 Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2653
33 diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
34 index 570d0c3..8a1e42a 100644
35 --- a/libtiff/tif_dirread.c
36 +++ b/libtiff/tif_dirread.c
37 @@ -2872,7 +2872,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedRational(TIFF* tif, TIFFD
38 m.l = direntry->tdir_offset.toff_long8;
39 if (tif->tif_flags&TIFF_SWAB)
40 TIFFSwabArrayOfLong(m.i,2);
41 - if (m.i[0]==0)
42 + /* Not completely sure what we should do when m.i[1]==0, but some */
43 + /* sanitizers do not like division by 0.0: */
44 + /* http://bugzilla.maptools.org/show_bug.cgi?id=2644 */
45 + if (m.i[0]==0 || m.i[1]==0)
46 *value=0.0;
47 else
48 *value=(double)m.i[0]/(double)m.i[1];
49 @@ -2900,7 +2903,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFF
50 m.l=direntry->tdir_offset.toff_long8;
51 if (tif->tif_flags&TIFF_SWAB)
52 TIFFSwabArrayOfLong(m.i,2);
53 - if ((int32)m.i[0]==0)
54 + /* Not completely sure what we should do when m.i[1]==0, but some */
55 + /* sanitizers do not like division by 0.0: */
56 + /* http://bugzilla.maptools.org/show_bug.cgi?id=2644 */
57 + if ((int32)m.i[0]==0 || m.i[1]==0)
58 *value=0.0;
59 else
60 *value=(double)((int32)m.i[0])/(double)m.i[1];