Fix CVE-2016-1026{6,7,8,9}, CVE-2016-1027{0,1,2} (#1438464)
This commit is contained in:
parent
9bb69388d9
commit
a25e4bc1af
43
libtiff-CVE-2016-10266.patch
Normal file
43
libtiff-CVE-2016-10266.patch
Normal file
@ -0,0 +1,43 @@
|
||||
From 438274f938e046d33cb0e1230b41da32ffe223e1 Mon Sep 17 00:00:00 2001
|
||||
From: erouault <erouault>
|
||||
Date: Fri, 2 Dec 2016 21:56:56 +0000
|
||||
Subject: [PATCH] * libtiff/tif_read.c, libtiff/tiffiop.h: fix uint32 overflow
|
||||
in TIFFReadEncodedStrip() that caused an integer division by zero. Reported
|
||||
by Agostino Sarubbo. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2596
|
||||
|
||||
---
|
||||
libtiff/tif_read.c | 2 +-
|
||||
libtiff/tiffiop.h | 4 ++++
|
||||
2 files changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c
|
||||
index c26c55f..52bbf50 100644
|
||||
--- a/libtiff/tif_read.c
|
||||
+++ b/libtiff/tif_read.c
|
||||
@@ -346,7 +346,7 @@ TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
|
||||
rowsperstrip=td->td_rowsperstrip;
|
||||
if (rowsperstrip>td->td_imagelength)
|
||||
rowsperstrip=td->td_imagelength;
|
||||
- stripsperplane=((td->td_imagelength+rowsperstrip-1)/rowsperstrip);
|
||||
+ stripsperplane= TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip);
|
||||
stripinplane=(strip%stripsperplane);
|
||||
plane=(uint16)(strip/stripsperplane);
|
||||
rows=td->td_imagelength-stripinplane*rowsperstrip;
|
||||
diff --git a/libtiff/tiffiop.h b/libtiff/tiffiop.h
|
||||
index ffbb647..cb59460 100644
|
||||
--- a/libtiff/tiffiop.h
|
||||
+++ b/libtiff/tiffiop.h
|
||||
@@ -250,6 +250,10 @@ struct tiff {
|
||||
#define TIFFhowmany_32(x, y) (((uint32)x < (0xffffffff - (uint32)(y-1))) ? \
|
||||
((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) : \
|
||||
0U)
|
||||
+/* Variant of TIFFhowmany_32() that doesn't return 0 if x close to MAXUINT. */
|
||||
+/* Caution: TIFFhowmany_32_maxuint_compat(x,y)*y might overflow */
|
||||
+#define TIFFhowmany_32_maxuint_compat(x, y) \
|
||||
+ (((uint32)(x) / (uint32)(y)) + ((((uint32)(x) % (uint32)(y)) != 0) ? 1 : 0))
|
||||
#define TIFFhowmany8_32(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3)
|
||||
#define TIFFroundup_32(x, y) (TIFFhowmany_32(x,y)*(y))
|
||||
#define TIFFhowmany_64(x, y) ((((uint64)(x))+(((uint64)(y))-1))/((uint64)(y)))
|
||||
--
|
||||
2.7.4
|
||||
|
50
libtiff-CVE-2016-10267.patch
Normal file
50
libtiff-CVE-2016-10267.patch
Normal file
@ -0,0 +1,50 @@
|
||||
From 43bc256d8ae44b92d2734a3c5bc73957a4d7c1ec Mon Sep 17 00:00:00 2001
|
||||
From: erouault <erouault>
|
||||
Date: Sat, 3 Dec 2016 11:15:18 +0000
|
||||
Subject: [PATCH] * libtiff/tif_ojpeg.c: make OJPEGDecode() early exit in case
|
||||
of failure in OJPEGPreDecode(). This will avoid a divide by zero, and
|
||||
potential other issues. Reported by Agostino Sarubbo. Fixes
|
||||
http://bugzilla.maptools.org/show_bug.cgi?id=2611
|
||||
|
||||
---
|
||||
libtiff/tif_ojpeg.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c
|
||||
index 1ccc3f9..f19e8fd 100644
|
||||
--- a/libtiff/tif_ojpeg.c
|
||||
+++ b/libtiff/tif_ojpeg.c
|
||||
@@ -244,6 +244,7 @@ typedef enum {
|
||||
|
||||
typedef struct {
|
||||
TIFF* tif;
|
||||
+ int decoder_ok;
|
||||
#ifndef LIBJPEG_ENCAP_EXTERNAL
|
||||
JMP_BUF exit_jmpbuf;
|
||||
#endif
|
||||
@@ -722,6 +723,7 @@ OJPEGPreDecode(TIFF* tif, uint16 s)
|
||||
}
|
||||
sp->write_curstrile++;
|
||||
}
|
||||
+ sp->decoder_ok = 1;
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -784,8 +786,14 @@ OJPEGPreDecodeSkipScanlines(TIFF* tif)
|
||||
static int
|
||||
OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
{
|
||||
+ static const char module[]="OJPEGDecode";
|
||||
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
||||
(void)s;
|
||||
+ if( !sp->decoder_ok )
|
||||
+ {
|
||||
+ TIFFErrorExt(tif->tif_clientdata,module,"Cannot decode: decoder not correctly initialized");
|
||||
+ return 0;
|
||||
+ }
|
||||
if (sp->libjpeg_jpeg_query_style==0)
|
||||
{
|
||||
if (OJPEGDecodeRaw(tif,buf,cc)==0)
|
||||
--
|
||||
2.7.4
|
||||
|
28
libtiff-CVE-2016-10268.patch
Normal file
28
libtiff-CVE-2016-10268.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From 5397a417e61258c69209904e652a1f409ec3b9df Mon Sep 17 00:00:00 2001
|
||||
From: erouault <erouault>
|
||||
Date: Fri, 2 Dec 2016 22:13:32 +0000
|
||||
Subject: [PATCH] * tools/tiffcp.c: avoid uint32 underflow in cpDecodedStrips
|
||||
that can cause various issues, such as buffer overflows in the library.
|
||||
Reported by Agostino Sarubbo. Fixes
|
||||
http://bugzilla.maptools.org/show_bug.cgi?id=2598
|
||||
|
||||
---
|
||||
tools/tiffcp.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tools/tiffcp.c b/tools/tiffcp.c
|
||||
index a99c906..f294ed1 100644
|
||||
--- a/tools/tiffcp.c
|
||||
+++ b/tools/tiffcp.c
|
||||
@@ -985,7 +985,7 @@ DECLAREcpFunc(cpDecodedStrips)
|
||||
tstrip_t s, ns = TIFFNumberOfStrips(in);
|
||||
uint32 row = 0;
|
||||
_TIFFmemset(buf, 0, stripsize);
|
||||
- for (s = 0; s < ns; s++) {
|
||||
+ for (s = 0; s < ns && row < imagelength; s++) {
|
||||
tsize_t cc = (row + rowsperstrip > imagelength) ?
|
||||
TIFFVStripSize(in, imagelength - row) : stripsize;
|
||||
if (TIFFReadEncodedStrip(in, s, buf, cc) < 0
|
||||
--
|
||||
2.7.4
|
||||
|
107
libtiff-CVE-2016-10269.patch
Normal file
107
libtiff-CVE-2016-10269.patch
Normal file
@ -0,0 +1,107 @@
|
||||
From 1044b43637fa7f70fb19b93593777b78bd20da86 Mon Sep 17 00:00:00 2001
|
||||
From: erouault <erouault>
|
||||
Date: Fri, 2 Dec 2016 23:05:51 +0000
|
||||
Subject: [PATCH] * libtiff/tif_pixarlog.c, libtiff/tif_luv.c: fix heap-based
|
||||
buffer overflow on generation of PixarLog / LUV compressed files, with
|
||||
ColorMap, TransferFunction attached and nasty plays with bitspersample. The
|
||||
fix for LUV has not been tested, but suffers from the same kind of issue of
|
||||
PixarLog. Reported by Agostino Sarubbo. Fixes
|
||||
http://bugzilla.maptools.org/show_bug.cgi?id=2604
|
||||
|
||||
---
|
||||
libtiff/tif_luv.c | 18 ++++++++++++++----
|
||||
libtiff/tif_pixarlog.c | 17 +++++++++++++++--
|
||||
2 files changed, 29 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c
|
||||
index f68a9b1..e6783db 100644
|
||||
--- a/libtiff/tif_luv.c
|
||||
+++ b/libtiff/tif_luv.c
|
||||
@@ -158,6 +158,7 @@
|
||||
typedef struct logLuvState LogLuvState;
|
||||
|
||||
struct logLuvState {
|
||||
+ int encoder_state; /* 1 if encoder correctly initialized */
|
||||
int user_datafmt; /* user data format */
|
||||
int encode_meth; /* encoding method */
|
||||
int pixel_size; /* bytes per pixel */
|
||||
@@ -1552,6 +1553,7 @@ LogLuvSetupEncode(TIFF* tif)
|
||||
td->td_photometric, "must be either LogLUV or LogL");
|
||||
break;
|
||||
}
|
||||
+ sp->encoder_state = 1;
|
||||
return (1);
|
||||
notsupported:
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
@@ -1563,19 +1565,27 @@ notsupported:
|
||||
static void
|
||||
LogLuvClose(TIFF* tif)
|
||||
{
|
||||
+ LogLuvState* sp = (LogLuvState*) tif->tif_data;
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
|
||||
+ assert(sp != 0);
|
||||
/*
|
||||
* For consistency, we always want to write out the same
|
||||
* bitspersample and sampleformat for our TIFF file,
|
||||
* regardless of the data format being used by the application.
|
||||
* Since this routine is called after tags have been set but
|
||||
* before they have been recorded in the file, we reset them here.
|
||||
+ * Note: this is really a nasty approach. See PixarLogClose
|
||||
*/
|
||||
- td->td_samplesperpixel =
|
||||
- (td->td_photometric == PHOTOMETRIC_LOGL) ? 1 : 3;
|
||||
- td->td_bitspersample = 16;
|
||||
- td->td_sampleformat = SAMPLEFORMAT_INT;
|
||||
+ if( sp->encoder_state )
|
||||
+ {
|
||||
+ /* See PixarLogClose. Might avoid issues with tags whose size depends
|
||||
+ * on those below, but not completely sure this is enough. */
|
||||
+ td->td_samplesperpixel =
|
||||
+ (td->td_photometric == PHOTOMETRIC_LOGL) ? 1 : 3;
|
||||
+ td->td_bitspersample = 16;
|
||||
+ td->td_sampleformat = SAMPLEFORMAT_INT;
|
||||
+ }
|
||||
}
|
||||
|
||||
static void
|
||||
diff --git a/libtiff/tif_pixarlog.c b/libtiff/tif_pixarlog.c
|
||||
index d1246c3..aa99bc9 100644
|
||||
--- a/libtiff/tif_pixarlog.c
|
||||
+++ b/libtiff/tif_pixarlog.c
|
||||
@@ -1233,8 +1233,10 @@ PixarLogPostEncode(TIFF* tif)
|
||||
static void
|
||||
PixarLogClose(TIFF* tif)
|
||||
{
|
||||
+ PixarLogState* sp = (PixarLogState*) tif->tif_data;
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
|
||||
+ assert(sp != 0);
|
||||
/* In a really sneaky (and really incorrect, and untruthful, and
|
||||
* troublesome, and error-prone) maneuver that completely goes against
|
||||
* the spirit of TIFF, and breaks TIFF, on close, we covertly
|
||||
@@ -1243,8 +1245,19 @@ PixarLogClose(TIFF* tif)
|
||||
* readers that don't know about PixarLog, or how to set
|
||||
* the PIXARLOGDATFMT pseudo-tag.
|
||||
*/
|
||||
- td->td_bitspersample = 8;
|
||||
- td->td_sampleformat = SAMPLEFORMAT_UINT;
|
||||
+
|
||||
+ if (sp->state&PLSTATE_INIT) {
|
||||
+ /* We test the state to avoid an issue such as in
|
||||
+ * http://bugzilla.maptools.org/show_bug.cgi?id=2604
|
||||
+ * What appends in that case is that the bitspersample is 1 and
|
||||
+ * a TransferFunction is set. The size of the TransferFunction
|
||||
+ * depends on 1<<bitspersample. So if we increase it, an access
|
||||
+ * out of the buffer will happen at directory flushing.
|
||||
+ * Another option would be to clear those targs.
|
||||
+ */
|
||||
+ td->td_bitspersample = 8;
|
||||
+ td->td_sampleformat = SAMPLEFORMAT_UINT;
|
||||
+ }
|
||||
}
|
||||
|
||||
static void
|
||||
--
|
||||
2.7.4
|
||||
|
103
libtiff-CVE-2016-10270.patch
Normal file
103
libtiff-CVE-2016-10270.patch
Normal file
@ -0,0 +1,103 @@
|
||||
From 9a72a69e035ee70ff5c41541c8c61cd97990d018 Mon Sep 17 00:00:00 2001
|
||||
From: erouault <erouault>
|
||||
Date: Sat, 3 Dec 2016 11:02:15 +0000
|
||||
Subject: [PATCH] * libtiff/tif_dirread.c: modify
|
||||
ChopUpSingleUncompressedStrip() to instanciate compute ntrips as
|
||||
TIFFhowmany_32(td->td_imagelength, rowsperstrip), instead of a logic based on
|
||||
the total size of data. Which is faulty is the total size of data is not
|
||||
sufficient to fill the whole image, and thus results in reading outside of
|
||||
the StripByCounts/StripOffsets arrays when using TIFFReadScanline(). Reported
|
||||
by Agostino Sarubbo. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2608.
|
||||
|
||||
* libtiff/tif_strip.c: revert the change in TIFFNumberOfStrips() done
|
||||
for http://bugzilla.maptools.org/show_bug.cgi?id=2587 / CVE-2016-9273 since
|
||||
the above change is a better fix that makes it unnecessary.
|
||||
---
|
||||
libtiff/tif_dirread.c | 22 ++++++++++------------
|
||||
libtiff/tif_strip.c | 9 ---------
|
||||
2 files changed, 10 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
|
||||
index 3eec79c..570d0c3 100644
|
||||
--- a/libtiff/tif_dirread.c
|
||||
+++ b/libtiff/tif_dirread.c
|
||||
@@ -5502,8 +5502,7 @@ ChopUpSingleUncompressedStrip(TIFF* tif)
|
||||
uint64 rowblockbytes;
|
||||
uint64 stripbytes;
|
||||
uint32 strip;
|
||||
- uint64 nstrips64;
|
||||
- uint32 nstrips32;
|
||||
+ uint32 nstrips;
|
||||
uint32 rowsperstrip;
|
||||
uint64* newcounts;
|
||||
uint64* newoffsets;
|
||||
@@ -5534,18 +5533,17 @@ ChopUpSingleUncompressedStrip(TIFF* tif)
|
||||
return;
|
||||
|
||||
/*
|
||||
- * never increase the number of strips in an image
|
||||
+ * never increase the number of rows per strip
|
||||
*/
|
||||
if (rowsperstrip >= td->td_rowsperstrip)
|
||||
return;
|
||||
- nstrips64 = TIFFhowmany_64(bytecount, stripbytes);
|
||||
- if ((nstrips64==0)||(nstrips64>0xFFFFFFFF)) /* something is wonky, do nothing. */
|
||||
- return;
|
||||
- nstrips32 = (uint32)nstrips64;
|
||||
+ nstrips = TIFFhowmany_32(td->td_imagelength, rowsperstrip);
|
||||
+ if( nstrips == 0 )
|
||||
+ return;
|
||||
|
||||
- newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips32, sizeof (uint64),
|
||||
+ newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64),
|
||||
"for chopped \"StripByteCounts\" array");
|
||||
- newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips32, sizeof (uint64),
|
||||
+ newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64),
|
||||
"for chopped \"StripOffsets\" array");
|
||||
if (newcounts == NULL || newoffsets == NULL) {
|
||||
/*
|
||||
@@ -5562,18 +5560,18 @@ ChopUpSingleUncompressedStrip(TIFF* tif)
|
||||
* Fill the strip information arrays with new bytecounts and offsets
|
||||
* that reflect the broken-up format.
|
||||
*/
|
||||
- for (strip = 0; strip < nstrips32; strip++) {
|
||||
+ for (strip = 0; strip < nstrips; strip++) {
|
||||
if (stripbytes > bytecount)
|
||||
stripbytes = bytecount;
|
||||
newcounts[strip] = stripbytes;
|
||||
- newoffsets[strip] = offset;
|
||||
+ newoffsets[strip] = stripbytes ? offset : 0;
|
||||
offset += stripbytes;
|
||||
bytecount -= stripbytes;
|
||||
}
|
||||
/*
|
||||
* Replace old single strip info with multi-strip info.
|
||||
*/
|
||||
- td->td_stripsperimage = td->td_nstrips = nstrips32;
|
||||
+ td->td_stripsperimage = td->td_nstrips = nstrips;
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
|
||||
|
||||
_TIFFfree(td->td_stripbytecount);
|
||||
diff --git a/libtiff/tif_strip.c b/libtiff/tif_strip.c
|
||||
index 4c46ecf..1676e47 100644
|
||||
--- a/libtiff/tif_strip.c
|
||||
+++ b/libtiff/tif_strip.c
|
||||
@@ -63,15 +63,6 @@ TIFFNumberOfStrips(TIFF* tif)
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint32 nstrips;
|
||||
|
||||
- /* If the value was already computed and store in td_nstrips, then return it,
|
||||
- since ChopUpSingleUncompressedStrip might have altered and resized the
|
||||
- since the td_stripbytecount and td_stripoffset arrays to the new value
|
||||
- after the initial affectation of td_nstrips = TIFFNumberOfStrips() in
|
||||
- tif_dirread.c ~line 3612.
|
||||
- See http://bugzilla.maptools.org/show_bug.cgi?id=2587 */
|
||||
- if( td->td_nstrips )
|
||||
- return td->td_nstrips;
|
||||
-
|
||||
nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
|
||||
TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
|
||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
|
||||
--
|
||||
2.7.4
|
||||
|
28
libtiff-CVE-2016-10271_10272.patch
Normal file
28
libtiff-CVE-2016-10271_10272.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From 9657bbe3cdce4aaa90e07d50c1c70ae52da0ba6a Mon Sep 17 00:00:00 2001
|
||||
From: erouault <erouault>
|
||||
Date: Sat, 3 Dec 2016 11:35:56 +0000
|
||||
Subject: [PATCH] * tools/tiffcrop.c: fix readContigStripsIntoBuffer() in -i
|
||||
(ignore) mode so that the output buffer is correctly incremented to avoid
|
||||
write outside bounds. Reported by Agostino Sarubbo. Fixes
|
||||
http://bugzilla.maptools.org/show_bug.cgi?id=2620
|
||||
|
||||
---
|
||||
tools/tiffcrop.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
|
||||
index b87a77a..70a71e1 100644
|
||||
--- a/tools/tiffcrop.c
|
||||
+++ b/tools/tiffcrop.c
|
||||
@@ -3698,7 +3698,7 @@ static int readContigStripsIntoBuffer (TIFF* in, uint8* buf)
|
||||
(unsigned long) strip, (unsigned long)rows);
|
||||
return 0;
|
||||
}
|
||||
- bufp += bytes_read;
|
||||
+ bufp += stripsize;
|
||||
}
|
||||
|
||||
return 1;
|
||||
--
|
||||
2.7.4
|
||||
|
17
libtiff.spec
17
libtiff.spec
@ -1,7 +1,7 @@
|
||||
Summary: Library of functions for manipulating TIFF format image files
|
||||
Name: libtiff
|
||||
Version: 4.0.7
|
||||
Release: 3%{?dist}
|
||||
Release: 4%{?dist}
|
||||
License: libtiff
|
||||
Group: System Environment/Libraries
|
||||
URL: http://www.simplesystems.org/libtiff/
|
||||
@ -11,6 +11,12 @@ Source: ftp://ftp.simplesystems.org/pub/libtiff/tiff-%{version}.tar.gz
|
||||
Patch0: libtiff-am-version.patch
|
||||
Patch1: libtiff-make-check.patch
|
||||
Patch2: libtiff-hylafax-fix.patch
|
||||
Patch3: libtiff-CVE-2016-10266.patch
|
||||
Patch4: libtiff-CVE-2016-10267.patch
|
||||
Patch5: libtiff-CVE-2016-10268.patch
|
||||
Patch6: libtiff-CVE-2016-10269.patch
|
||||
Patch7: libtiff-CVE-2016-10270.patch
|
||||
Patch8: libtiff-CVE-2016-10271_10272.patch
|
||||
|
||||
BuildRequires: zlib-devel libjpeg-devel jbigkit-devel
|
||||
BuildRequires: libtool automake autoconf pkgconfig
|
||||
@ -64,6 +70,12 @@ image files using the libtiff library.
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
%patch6 -p1
|
||||
%patch7 -p1
|
||||
%patch8 -p1
|
||||
|
||||
# Use build system's libtool.m4, not the one in the package.
|
||||
rm -f libtool.m4
|
||||
@ -169,6 +181,9 @@ find html -name 'Makefile*' | xargs rm
|
||||
%{_mandir}/man1/*
|
||||
|
||||
%changelog
|
||||
* Wed Apr 05 2017 Nikola Forró <nforro@redhat.com> - 4.0.7-4
|
||||
- Fix CVE-2016-1026{6,7,8,9}, CVE-2016-1027{0,1,2} (#1438464)
|
||||
|
||||
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.7-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user