Merge pull request #4853 from StevenHessing/noddos
[feed/packages.git] / libs / tiff / patches / 016-CVE-2017-10688.patch
1 From 6173a57d39e04d68b139f8c1aa499a24dbe74ba1 Mon Sep 17 00:00:00 2001
2 From: Even Rouault <even.rouault@spatialys.com>
3 Date: Fri, 30 Jun 2017 17:29:44 +0000
4 Subject: [PATCH] * libtiff/tif_dirwrite.c: in
5 TIFFWriteDirectoryTagCheckedXXXX() functions associated with LONG8/SLONG8
6 data type, replace assertion that the file is BigTIFF, by a non-fatal error.
7 Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2712 Reported by team
8 OWL337
9
10 ---
11 ChangeLog | 8 ++++++++
12 libtiff/tif_dirwrite.c | 20 ++++++++++++++++----
13 2 files changed, 24 insertions(+), 4 deletions(-)
14
15 diff --git a/ChangeLog b/ChangeLog
16 index 6f085e09..77a64385 100644
17 --- a/ChangeLog
18 +++ b/ChangeLog
19 @@ -1,5 +1,13 @@
20 2017-06-30 Even Rouault <even.rouault at spatialys.com>
21
22 + * libtiff/tif_dirwrite.c: in TIFFWriteDirectoryTagCheckedXXXX()
23 + functions associated with LONG8/SLONG8 data type, replace assertion that
24 + the file is BigTIFF, by a non-fatal error.
25 + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2712
26 + Reported by team OWL337
27 +
28 +2017-06-30 Even Rouault <even.rouault at spatialys.com>
29 +
30 * libtiff/tif_read.c, tiffiop.h: add a _TIFFReadEncodedStripAndAllocBuffer()
31 function, variant of TIFFReadEncodedStrip() that allocates the
32 decoded buffer only after a first successful TIFFFillStrip(). This avoids
33 diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
34 index 2967da58..8d6686ba 100644
35 --- a/libtiff/tif_dirwrite.c
36 +++ b/libtiff/tif_dirwrite.c
37 @@ -2111,7 +2111,10 @@ TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui
38 {
39 uint64 m;
40 assert(sizeof(uint64)==8);
41 - assert(tif->tif_flags&TIFF_BIGTIFF);
42 + if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
43 + TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8","LONG8 not allowed for ClassicTIFF");
44 + return(0);
45 + }
46 m=value;
47 if (tif->tif_flags&TIFF_SWAB)
48 TIFFSwabLong8(&m);
49 @@ -2124,7 +2127,10 @@ TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* di
50 {
51 assert(count<0x20000000);
52 assert(sizeof(uint64)==8);
53 - assert(tif->tif_flags&TIFF_BIGTIFF);
54 + if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
55 + TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8","LONG8 not allowed for ClassicTIFF");
56 + return(0);
57 + }
58 if (tif->tif_flags&TIFF_SWAB)
59 TIFFSwabArrayOfLong8(value,count);
60 return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG8,count,count*8,value));
61 @@ -2136,7 +2142,10 @@ TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, u
62 {
63 int64 m;
64 assert(sizeof(int64)==8);
65 - assert(tif->tif_flags&TIFF_BIGTIFF);
66 + if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
67 + TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8","SLONG8 not allowed for ClassicTIFF");
68 + return(0);
69 + }
70 m=value;
71 if (tif->tif_flags&TIFF_SWAB)
72 TIFFSwabLong8((uint64*)(&m));
73 @@ -2149,7 +2158,10 @@ TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* d
74 {
75 assert(count<0x20000000);
76 assert(sizeof(int64)==8);
77 - assert(tif->tif_flags&TIFF_BIGTIFF);
78 + if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
79 + TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8","SLONG8 not allowed for ClassicTIFF");
80 + return(0);
81 + }
82 if (tif->tif_flags&TIFF_SWAB)
83 TIFFSwabArrayOfLong8((uint64*)value,count);
84 return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,count,count*8,value));