public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/
@ 2017-04-10 21:49 Mike Frysinger
  0 siblings, 0 replies; 13+ messages in thread
From: Mike Frysinger @ 2017-04-10 21:49 UTC (permalink / raw
  To: gentoo-commits

commit:     9108af32a69a8d05b8d03b3b9adb9e0a7a5783bb
Author:     Mike Frysinger <vapier <AT> chromium <DOT> org>
AuthorDate: Mon Apr 10 21:42:58 2017 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Apr 10 21:45:14 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9108af32

media-libs/tiff: pull in pdfium security patches

 ....0.7-pdfium-0005-Leak-TIFFFetchStripThing.patch |  20 ++++
 ...ferOverflow-ChopUpSingleUncompressedStrip.patch |  34 ++++++
 ...iff-4.0.7-pdfium-0007-uninitialized-value.patch |  26 +++++
 ...ferOverflow-ChopUpSingleUncompressedStrip.patch |  26 +++++
 ...-4.0.7-pdfium-0013-validate-refblackwhite.patch |  41 +++++++
 ....7-pdfium-0017-safe_skews_in_gtTileContig.patch |  97 +++++++++++++++++
 ...ium-0018-fix-leak-in-PredictorSetupDecode.patch |  27 +++++
 .../tiff-4.0.7-pdfium-0021-oom-TIFFFillStrip.patch |  29 +++++
 media-libs/tiff/tiff-4.0.7-r2.ebuild               | 121 +++++++++++++++++++++
 9 files changed, 421 insertions(+)

diff --git a/media-libs/tiff/files/tiff-4.0.7-pdfium-0005-Leak-TIFFFetchStripThing.patch b/media-libs/tiff/files/tiff-4.0.7-pdfium-0005-Leak-TIFFFetchStripThing.patch
new file mode 100644
index 00000000000..afb0151f963
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.7-pdfium-0005-Leak-TIFFFetchStripThing.patch
@@ -0,0 +1,20 @@
+https://codereview.chromium.org/2204793002
+https://crbug.com/633387
+https://pdfium.googlesource.com/pdfium/+/master/libtiff/
+
+Author: thestig <thestig@chromium.org>
+Date:   Mon Aug 1 19:36:27 2016 -0700
+
+Fix a memory leak in libtiff.
+
+--- a/libtiff/tif_dirread.c
++++ b/libtiff/tif_dirread.c
+@@ -5372,6 +5372,8 @@ TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp)
+ 	static const char module[] = "TIFFFetchStripThing";
+ 	enum TIFFReadDirEntryErr err;
+ 	uint64* data;
++	_TIFFfree(*lpp);
++	*lpp = 0;
+ 	err=TIFFReadDirEntryLong8Array(tif,dir,&data);
+ 	if (err!=TIFFReadDirEntryErrOk)
+ 	{

diff --git a/media-libs/tiff/files/tiff-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch b/media-libs/tiff/files/tiff-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
new file mode 100644
index 00000000000..f573fd9deb3
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
@@ -0,0 +1,34 @@
+https://codereview.chromium.org/2284063002
+https://crbug.com/618267
+https://pdfium.googlesource.com/pdfium/+/master/libtiff/
+
+Author: tracy_jiang <tracy_jiang@foxitsoftware.com>
+Date:   Mon Aug 29 13:42:56 2016 -0700
+
+Fix for #618267. Adding a method to determine if multiplication has
+overflow.
+
+--- a/libtiff/tif_aux.c
++++ b/libtiff/tif_aux.c
+@@ -69,7 +69,7 @@ _TIFFCheckRealloc(TIFF* tif, void* buffer,
+ 	/*
+ 	 * XXX: Check for integer overflow.
+ 	 */
+-	if (nmemb && elem_size && bytes / elem_size == nmemb)
++	if (nmemb && elem_size && !_TIFFIfMultiplicationOverflow(nmemb, elem_size))
+ 		cp = _TIFFrealloc(buffer, bytes);
+ 
+ 	if (cp == NULL) {
+--- a/libtiff/tiffio.h
++++ b/libtiff/tiffio.h
+@@ -298,6 +298,10 @@ extern void _TIFFmemset(void* p, int v, tmsize_t c);
+ extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c);
+ extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c);
+ extern void _TIFFfree(void* p);
++#include <limits.h>
++static inline int _TIFFIfMultiplicationOverflow(tmsize_t op1, tmsize_t op2) {
++  return op1 > SSIZE_MAX / op2;
++}
+ 
+ /*
+ ** Stuff, related to tag handling and creating custom tags.

diff --git a/media-libs/tiff/files/tiff-4.0.7-pdfium-0007-uninitialized-value.patch b/media-libs/tiff/files/tiff-4.0.7-pdfium-0007-uninitialized-value.patch
new file mode 100644
index 00000000000..ab5627f5c16
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.7-pdfium-0007-uninitialized-value.patch
@@ -0,0 +1,26 @@
+https://codereview.chromium.org/2389993002
+https://crbug.com/651632
+https://pdfium.googlesource.com/pdfium/+/master/libtiff/
+
+Author: dsinclair <dsinclair@chromium.org>
+Date:   Mon Oct 3 13:59:57 2016 -0700
+
+Fix potentially uninitialized value.
+
+Depending on what ReadOK does it's possible for |dircount16| to be used without
+being initialized. The read code calls back into PDFium specific code which then
+calls into the stream reading code.
+
+Initialize the value to be sure it is set.
+
+--- a/libtiff/tif_dirread.c
++++ b/libtiff/tif_dirread.c
+@@ -4443,7 +4443,7 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir,
+ 	static const char module[] = "TIFFFetchDirectory";
+ 
+ 	void* origdir;
+-	uint16 dircount16;
++	uint16 dircount16 = 0;
+ 	uint32 dirsize;
+ 	TIFFDirEntry* dir;
+ 	uint8* ma;

diff --git a/media-libs/tiff/files/tiff-4.0.7-pdfium-0008-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch b/media-libs/tiff/files/tiff-4.0.7-pdfium-0008-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
new file mode 100644
index 00000000000..35f59b9bffd
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.7-pdfium-0008-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
@@ -0,0 +1,26 @@
+https://codereview.chromium.org/2405693002
+https://crbug.com/654169
+https://pdfium.googlesource.com/pdfium/+/master/libtiff/
+
+Author: stackexploit <stackexploit@gmail.com>
+Date:   Mon Oct 10 10:58:25 2016 -0700
+
+libtiff: Prevent a buffer overflow in function ChopUpSingleUncompressedStrip.
+
+The patch (https://codereview.chromium.org/2284063002) for Issue 618267
+was insufficient. The integer overflow still could be triggered and could
+lead to heap buffer overflow.
+
+This CL strengthens integer overflow check in function _TIFFCheckRealloc.
+
+--- a/libtiff/tif_aux.c
++++ b/libtiff/tif_aux.c
+@@ -69,7 +69,7 @@ _TIFFCheckRealloc(TIFF* tif, void* buffer,
+ 	/*
+ 	 * XXX: Check for integer overflow.
+ 	 */
+-	if (nmemb && elem_size && !_TIFFIfMultiplicationOverflow(nmemb, elem_size))
++	if (nmemb > 0 && elem_size > 0 && !_TIFFIfMultiplicationOverflow(nmemb, elem_size))
+ 		cp = _TIFFrealloc(buffer, bytes);
+ 
+ 	if (cp == NULL) {

diff --git a/media-libs/tiff/files/tiff-4.0.7-pdfium-0013-validate-refblackwhite.patch b/media-libs/tiff/files/tiff-4.0.7-pdfium-0013-validate-refblackwhite.patch
new file mode 100644
index 00000000000..47a3db06431
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.7-pdfium-0013-validate-refblackwhite.patch
@@ -0,0 +1,41 @@
+https://pdfium-review.googlesource.com/2151
+https://crbug.com/632883
+https://pdfium.googlesource.com/pdfium/+/master/libtiff/
+
+Author: Dan Sinclair <dsinclair@chromium.org>
+Date:   Mon Jan 9 09:50:50 2017 -0500
+
+[libtiff] Validate refblackwhite values
+
+The td_refblackwhite value is currently assigned without validation. This
+may pose an issue as the image can specify the value as nan. This will cause
+problems later when we use the nan in calcluations.
+
+This CL validates each of the float values are not nan and if they are sets
+them to the default provided by the TIFF spec v6.
+
+--- a/libtiff/tif_dir.c
++++ b/libtiff/tif_dir.c
+@@ -31,6 +31,7 @@
+  * (and also some miscellaneous stuff)
+  */
+ #include "tiffiop.h"
++#include <math.h>
+ #include <float.h>
+ 
+ /*
+@@ -426,6 +426,14 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
+ 	case TIFFTAG_REFERENCEBLACKWHITE:
+ 		/* XXX should check for null range */
+ 		_TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6);
++		for (int i = 0; i < 6; i++) {
++			if (isnan(td->td_refblackwhite[i])) {
++				if (i % 2 == 0)
++					td->td_refblackwhite[i] = 0;
++				else
++					td->td_refblackwhite[i] = pow(2, td->td_bitspersample) - 1;
++			}
++		}
+ 		break;
+ 	case TIFFTAG_INKNAMES:
+ 		v = (uint16) va_arg(ap, uint16_vap);

diff --git a/media-libs/tiff/files/tiff-4.0.7-pdfium-0017-safe_skews_in_gtTileContig.patch b/media-libs/tiff/files/tiff-4.0.7-pdfium-0017-safe_skews_in_gtTileContig.patch
new file mode 100644
index 00000000000..7914743393f
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.7-pdfium-0017-safe_skews_in_gtTileContig.patch
@@ -0,0 +1,97 @@
+https://pdfium-review.googlesource.com/2355
+https://crbug.com/681300
+https://pdfium.googlesource.com/pdfium/+/master/libtiff/
+
+Author: Nicolas Pena <npm@chromium.org>
+Date:   Wed Jan 25 10:41:06 2017 -0500
+
+Prevent skew overflows in gtTileContig
+
+Using int64 to check whether uint32 operations have overflowed.
+
+--- a/libtiff/tif_getimage.c
++++ b/libtiff/tif_getimage.c
+@@ -31,6 +31,7 @@
+  */
+ #include "tiffiop.h"
+ #include <stdio.h>
++#include <limits.h>
+ 
+ static int gtTileContig(TIFFRGBAImage*, uint32*, uint32, uint32);
+ static int gtTileSeparate(TIFFRGBAImage*, uint32*, uint32, uint32);
+@@ -629,6 +628,7 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
+     uint32 tw, th;
+     unsigned char* buf;
+     int32 fromskew, toskew;
++    int64 safeskew;
+     uint32 nrow;
+     int ret = 1, flip;
+     uint32 this_tw, tocol;
+@@ -649,19 +647,37 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
+     flip = setorientation(img);
+     if (flip & FLIP_VERTICALLY) {
+ 	    y = h - 1;
+-	    toskew = -(int32)(tw + w);
++	    safeskew = 0;
++	    safeskew -= tw;
++	    safeskew -= w;
+     }
+     else {
+ 	    y = 0;
+-	    toskew = -(int32)(tw - w);
++	    safeskew = 0;
++	    safeskew -= tw;
++	    safeskew +=w;
+     }
+      
++    if(safeskew > INT_MAX || safeskew < INT_MIN){
++       _TIFFfree(buf);
++       TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "Invalid skew");
++       return (0);
++    }
++    toskew = safeskew;
++
+     /*
+      *	Leftmost tile is clipped on left side if col_offset > 0.
+      */
+     leftmost_fromskew = img->col_offset % tw;
+     leftmost_tw = tw - leftmost_fromskew;
+-    leftmost_toskew = toskew + leftmost_fromskew;
++    safeskew = toskew;
++    safeskew += leftmost_fromskew;
++    if(safeskew > INT_MAX || safeskew < INT_MIN){
++       _TIFFfree(buf);
++       TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "Invalid skew");
++       return (0);
++    }
++    leftmost_toskew = safeskew;
+     for (row = 0; row < h; row += nrow)
+     {
+         rowstoread = th - (row + img->row_offset) % th;
+@@ -704,9 +684,24 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
+ 		/*
+ 		 * Rightmost tile is clipped on right side.
+ 		 */
+-		fromskew = tw - (w - tocol);
++		safeskew = tw;
++		safeskew -= w;
++		safeskew += tocol;
++		if(safeskew > INT_MAX || safeskew < INT_MIN){
++		        _TIFFfree(buf);
++		        TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "Invalid skew");
++		        return (0);
++		}
++		fromskew = safeskew;
+ 		this_tw = tw - fromskew;
+-		this_toskew = toskew + fromskew;
++		safeskew = toskew;
++		safeskew += fromskew;
++		if(safeskew > INT_MAX || safeskew < INT_MIN){
++		        _TIFFfree(buf);
++		        TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "Invalid skew");
++		        return (0);
++		}
++		this_toskew = safeskew;
+ 	    }
+ 	    (*put)(img, raster+y*w+tocol, tocol, y, this_tw, nrow, fromskew, this_toskew, buf + pos);
+ 	    tocol += this_tw;

diff --git a/media-libs/tiff/files/tiff-4.0.7-pdfium-0018-fix-leak-in-PredictorSetupDecode.patch b/media-libs/tiff/files/tiff-4.0.7-pdfium-0018-fix-leak-in-PredictorSetupDecode.patch
new file mode 100644
index 00000000000..b74ddc5c499
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.7-pdfium-0018-fix-leak-in-PredictorSetupDecode.patch
@@ -0,0 +1,27 @@
+https://pdfium-review.googlesource.com/2432
+https://crbug.com/683834
+https://pdfium.googlesource.com/pdfium/+/master/libtiff/
+
+Author: Nicolas Pena <npm@chromium.org>
+Date:   Thu Jan 26 15:45:02 2017 -0500
+
+Fix leak in PredictorSetupDecode by calling tif_cleanup on failure
+
+tif_data and tif_cleanup are both set on the TIFFInit methods, see for
+instance TIFFInitPixarLog. If PredictorSetupDecode fails, whatever was
+filled on tif_data should be cleaned up. The previous leak fix from
+PixarLogSetupDecode is no longer necessary.
+
+--- a/libtiff/tif_predict.c
++++ b/libtiff/tif_predict.c
+@@ -118,7 +118,10 @@ PredictorSetupDecode(TIFF* tif)
+ 	TIFFDirectory* td = &tif->tif_dir;
+ 
+ 	if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif))
++	{
++		(*tif->tif_cleanup)(tif);
+ 		return 0;
++	}
+ 
+ 	if (sp->predictor == 2) {
+ 		switch (td->td_bitspersample) {

diff --git a/media-libs/tiff/files/tiff-4.0.7-pdfium-0021-oom-TIFFFillStrip.patch b/media-libs/tiff/files/tiff-4.0.7-pdfium-0021-oom-TIFFFillStrip.patch
new file mode 100644
index 00000000000..11975cf38ac
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.7-pdfium-0021-oom-TIFFFillStrip.patch
@@ -0,0 +1,29 @@
+https://pdfium-review.googlesource.com/3811
+https://crbug.com/707431
+https://pdfium.googlesource.com/pdfium/+/master/libtiff/
+
+Author: Nicolas Pena <npm@chromium.org>
+Date:   Wed Apr 5 15:50:53 2017 -0400
+
+Libtiff: Prevent OOM in TIFFFillStrip
+
+In TIFFFillStrip, calls to TIFFReadBufferSetup may allocate large amounts of
+memory. In this CL we do sanity checks on the claimed size of the raw strip
+data before that happens, to prevent out-of-memory.
+
+--- a/libtiff/tif_read.c
++++ b/libtiff/tif_read.c
+@@ -616,6 +616,13 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
+ 				TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
+ 				return(0);
+ 			}
++                       const tmsize_t size=isMapped(tif)? tif->tif_size : (tmsize_t)TIFFGetFileSize(tif);
++                       if (bytecountm > size) {
++                               TIFFErrorExt(tif->tif_clientdata, module,
++                                       "Requested read strip size %lu is too large",
++                                       (unsigned long) strip);
++                               return (0);
++                       }
+ 			if (bytecountm > tif->tif_rawdatasize) {
+ 				tif->tif_curstrip = NOSTRIP;
+ 				if ((tif->tif_flags & TIFF_MYBUFFER) == 0) {

diff --git a/media-libs/tiff/tiff-4.0.7-r2.ebuild b/media-libs/tiff/tiff-4.0.7-r2.ebuild
new file mode 100644
index 00000000000..b77d5196171
--- /dev/null
+++ b/media-libs/tiff/tiff-4.0.7-r2.ebuild
@@ -0,0 +1,121 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="6"
+inherit autotools eutils libtool multilib-minimal
+
+DESCRIPTION="Tag Image File Format (TIFF) library"
+HOMEPAGE="http://libtiff.maptools.org"
+SRC_URI="http://download.osgeo.org/libtiff/${P}.tar.gz
+	ftp://ftp.remotesensing.org/pub/libtiff/${P}.tar.gz"
+
+LICENSE="libtiff"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x64-cygwin ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~x64-solaris ~x86-solaris"
+IUSE="+cxx jbig jpeg lzma static-libs test zlib"
+
+RDEPEND="jpeg? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
+	jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
+	lzma? ( >=app-arch/xz-utils-5.0.5-r1:=[${MULTILIB_USEDEP}] )
+	zlib? ( >=sys-libs/zlib-1.2.8-r1:=[${MULTILIB_USEDEP}] )
+	abi_x86_32? (
+		!<=app-emulation/emul-linux-x86-baselibs-20130224-r9
+		!app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
+	)"
+DEPEND="${RDEPEND}"
+
+REQUIRED_USE="test? ( jpeg )" #483132
+
+PATCHES=(
+	"${FILESDIR}"/${P}-fax2tiff.patch #598938
+	"${FILESDIR}"/${P}-CVE-2016-10266.patch
+	"${FILESDIR}"/${P}-bug2598.patch
+	"${FILESDIR}"/${P}-bug2604.patch
+	"${FILESDIR}"/${P}-bug2608.patch
+	"${FILESDIR}"/${P}-CVE-2016-10267.patch
+	"${FILESDIR}"/${P}-bug2620.patch
+	"${FILESDIR}"/${P}-bug2621.patch
+	"${FILESDIR}"/${P}-bug2619.patch
+	"${FILESDIR}"/${P}-bug2594.patch
+	"${FILESDIR}"/${P}-bug2597.patch
+	"${FILESDIR}"/${P}-bug2599.patch
+	"${FILESDIR}"/${P}-bug2607.patch
+	"${FILESDIR}"/${P}-bug2610.patch
+	"${FILESDIR}"/${P}-bug2605.patch
+	"${FILESDIR}"/${P}-hylafax-hack.patch #612172
+	"${FILESDIR}"/${P}-bug2633-bug2634.patch
+	"${FILESDIR}"/${P}-bug2635.patch
+	"${FILESDIR}"/${P}-bug2627.patch
+	"${FILESDIR}"/${P}-bug2638.patch
+	"${FILESDIR}"/${P}-bug2639.patch
+	"${FILESDIR}"/${P}-bug2640.patch
+	"${FILESDIR}"/${P}-bug2653.patch
+	"${FILESDIR}"/${P}-bug2535.patch
+	"${FILESDIR}"/${P}-bug2644.patch
+	"${FILESDIR}"/${P}-bug2642-bug2643-bug2646-bug2647.patch
+	"${FILESDIR}"/${P}-bug2648.patch
+	"${FILESDIR}"/${P}-bug2650.patch
+	"${FILESDIR}"/${P}-bug2658.patch
+	"${FILESDIR}"/${P}-bug2650-2.patch
+	"${FILESDIR}"/${P}-bug2651.patch
+	"${FILESDIR}"/${P}-CVE-2017-5225.patch #610330
+	"${FILESDIR}"/${P}-bug2130.patch
+	"${FILESDIR}"/${P}-bug2659.patch
+	"${FILESDIR}"/${P}-bug2659-2.patch
+	"${FILESDIR}"/${P}-bug2631.patch
+	"${FILESDIR}"/${P}-bug2665.patch
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0005-Leak-TIFFFetchStripThing.patch
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0007-uninitialized-value.patch
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0008-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0013-validate-refblackwhite.patch
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0017-safe_skews_in_gtTileContig.patch
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0018-fix-leak-in-PredictorSetupDecode.patch
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0021-oom-TIFFFillStrip.patch
+)
+
+MULTILIB_WRAPPED_HEADERS=(
+	/usr/include/tiffconf.h
+)
+
+src_prepare() {
+	default
+
+	# tiffcp-thumbnail.sh fails as thumbnail binary doesn't get built anymore since tiff-4.0.7
+	sed '/tiffcp-thumbnail\.sh/d' -i test/Makefile.am || die
+
+	eautoreconf
+}
+
+multilib_src_configure() {
+	ECONF_SOURCE="${S}" econf \
+		$(use_enable static-libs static) \
+		$(use_enable zlib) \
+		$(use_enable jpeg) \
+		$(use_enable jbig) \
+		$(use_enable lzma) \
+		$(use_enable cxx) \
+		--without-x
+
+	# remove useless subdirs
+	if ! multilib_is_native_abi ; then
+		sed -i \
+			-e 's/ tools//' \
+			-e 's/ contrib//' \
+			-e 's/ man//' \
+			-e 's/ html//' \
+			Makefile || die
+	fi
+}
+
+multilib_src_test() {
+	if ! multilib_is_native_abi ; then
+		emake -C tools
+	fi
+	emake check
+}
+
+multilib_src_install_all() {
+	prune_libtool_files --all
+	rm -f "${ED}"/usr/share/doc/${PF}/{COPYRIGHT,README*,RELEASE-DATE,TODO,VERSION}
+}


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/
@ 2017-04-12 19:30 Mike Frysinger
  0 siblings, 0 replies; 13+ messages in thread
From: Mike Frysinger @ 2017-04-12 19:30 UTC (permalink / raw
  To: gentoo-commits

commit:     f383efc4136c911abc8542073a34f2cc6038ee3a
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Wed Apr 12 19:13:34 2017 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Wed Apr 12 19:25:37 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f383efc4

media-libs/tiff: update pdfium patches to be more portable

Put helper funcs in the private headers, and stick to older C standards.

 ...ferOverflow-ChopUpSingleUncompressedStrip.patch | 23 +++++++++++-----------
 ...-4.0.7-pdfium-0013-validate-refblackwhite.patch |  5 +++--
 .../{tiff-4.0.7-r2.ebuild => tiff-4.0.7-r3.ebuild} |  0
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/media-libs/tiff/files/tiff-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch b/media-libs/tiff/files/tiff-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
index f573fd9deb3..a45ee342f77 100644
--- a/media-libs/tiff/files/tiff-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
+++ b/media-libs/tiff/files/tiff-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
@@ -19,16 +19,15 @@ overflow.
  		cp = _TIFFrealloc(buffer, bytes);
  
  	if (cp == NULL) {
---- a/libtiff/tiffio.h
-+++ b/libtiff/tiffio.h
-@@ -298,6 +298,10 @@ extern void _TIFFmemset(void* p, int v, tmsize_t c);
- extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c);
- extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c);
- extern void _TIFFfree(void* p);
-+#include <limits.h>
-+static inline int _TIFFIfMultiplicationOverflow(tmsize_t op1, tmsize_t op2) {
-+  return op1 > SSIZE_MAX / op2;
-+}
+--- a/libtiff/tiffiop.h
++++ b/libtiff/tiffiop.h
+@@ -315,6 +315,9 @@ typedef size_t TIFFIOSize_t;
+ #define _TIFF_off_t off_t
+ #endif
  
- /*
- ** Stuff, related to tag handling and creating custom tags.
++#include <limits.h>
++#define _TIFFIfMultiplicationOverflow(op1, op2) ((op1) > SSIZE_MAX / (op2))
++
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif

diff --git a/media-libs/tiff/files/tiff-4.0.7-pdfium-0013-validate-refblackwhite.patch b/media-libs/tiff/files/tiff-4.0.7-pdfium-0013-validate-refblackwhite.patch
index 47a3db06431..d98ff9d0f25 100644
--- a/media-libs/tiff/files/tiff-4.0.7-pdfium-0013-validate-refblackwhite.patch
+++ b/media-libs/tiff/files/tiff-4.0.7-pdfium-0013-validate-refblackwhite.patch
@@ -24,11 +24,12 @@ them to the default provided by the TIFF spec v6.
  #include <float.h>
  
  /*
-@@ -426,6 +426,14 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
+@@ -426,6 +426,15 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
  	case TIFFTAG_REFERENCEBLACKWHITE:
  		/* XXX should check for null range */
  		_TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6);
-+		for (int i = 0; i < 6; i++) {
++		int i;
++		for (i = 0; i < 6; i++) {
 +			if (isnan(td->td_refblackwhite[i])) {
 +				if (i % 2 == 0)
 +					td->td_refblackwhite[i] = 0;

diff --git a/media-libs/tiff/tiff-4.0.7-r2.ebuild b/media-libs/tiff/tiff-4.0.7-r3.ebuild
similarity index 100%
rename from media-libs/tiff/tiff-4.0.7-r2.ebuild
rename to media-libs/tiff/tiff-4.0.7-r3.ebuild


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/
@ 2017-05-22  7:35 Lars Wendler
  0 siblings, 0 replies; 13+ messages in thread
From: Lars Wendler @ 2017-05-22  7:35 UTC (permalink / raw
  To: gentoo-commits

commit:     e85f99863e467882ba64febcec829ace775de1ea
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Mon May 22 07:34:15 2017 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Mon May 22 07:35:18 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e85f9986

media-libs/tiff: Removed old.

Package-Manager: Portage-2.3.6, Repoman-2.3.2

 media-libs/tiff/Manifest                           |   1 -
 .../tiff/files/tiff-4.0.6-gif2tiff_removal.patch   |  47 ---------
 media-libs/tiff/tiff-4.0.6-r1.ebuild               |  73 -------------
 media-libs/tiff/tiff-4.0.6.ebuild                  |  69 -------------
 media-libs/tiff/tiff-4.0.7-r1.ebuild               | 113 ---------------------
 5 files changed, 303 deletions(-)

diff --git a/media-libs/tiff/Manifest b/media-libs/tiff/Manifest
index bbc633fbc04..882ad79ea91 100644
--- a/media-libs/tiff/Manifest
+++ b/media-libs/tiff/Manifest
@@ -1,4 +1,3 @@
 DIST tiff-3.9.7.tar.gz 1468097 SHA256 f5d64dd4ce61c55f5e9f6dc3920fbe5a41e02c2e607da7117a35eb5c320cef6a SHA512 ca89584a9ffa33b4986e4bc2165043cec239896f1f0ab73db00818d0442b570efaa6345b2ed422e884202324d359713df849bf14782bb0cf3b959655febddd77 WHIRLPOOL c06b35da66c365c1fe7f0e6e06a400e139d3e2b5b280aa764015c2f0383a6191ffb3d335cdf2211b687bbb0caacf641be409148986a9813dfde5822a650a9b1c
-DIST tiff-4.0.6.tar.gz 2192991 SHA256 4d57a50907b510e3049a4bba0d7888930fdfc16ce49f1bf693e5b6247370d68c SHA512 2c8dbaaaab9f82a7722bfe8cb6fcfcf67472beb692f1b7dafaf322759e7016dad1bc58457c0f03db50aa5bd088fef2b37358fcbc1524e20e9e14a9620373fdf8 WHIRLPOOL 809e61a22f7d6dfdf81917a084678ec39ed3cff4e03184d61c67501946d3fab0645cb3fe800d9249771879ee91245085e123349f68340bb63bd18024db8e03a6
 DIST tiff-4.0.7.tar.gz 2076392 SHA256 9f43a2cfb9589e5cecaa66e16bf87f814c945f22df7ba600d63aac4632c4f019 SHA512 941357bdd5f947cdca41a1d31ae14b3fadc174ae5dce7b7981dbe58f61995f575ac2e97a7cc4fcc435184012017bec0920278263490464644f2cdfad9a6c5ddc WHIRLPOOL 3090a0d8a5ad3595c97888edab3c48379175cad993567d20be5f397b1c5c1d21012de55c5da5e664ee483d294fe9eb5f3464e14f564fb79c1357094ff67e313d
 DIST tiff-4.0.8.tar.gz 2065574 SHA256 59d7a5a8ccd92059913f246877db95a2918e6c04fb9d43fd74e5c3390dac2910 SHA512 5d010ec4ce37aca733f7ab7db9f432987b0cd21664bd9d99452a146833c40f0d1e7309d1870b0395e947964134d5cfeb1366181e761fe353ad585803ff3d6be6 WHIRLPOOL 13fce447c586fef080c6201f0f5b010bc8b0e096bc9b806ab3b80eb6a672c789f88b5fc34a51585aa7072bb8407ecc958d1d7824fad379f86968f051de2fa96d

diff --git a/media-libs/tiff/files/tiff-4.0.6-gif2tiff_removal.patch b/media-libs/tiff/files/tiff-4.0.6-gif2tiff_removal.patch
deleted file mode 100644
index ea5c2c32714..00000000000
--- a/media-libs/tiff/files/tiff-4.0.6-gif2tiff_removal.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-# Removing vulnerable gif2tiff (CVE-2016-5102)
-# Upstream seems to no longer ship this tool with >=tiff-4.0.7 versions.
-
-http://bugzilla.maptools.org/show_bug.cgi?id=2552
-https://bugzilla.redhat.com/show_bug.cgi?id=1343407
-https://bugs.gentoo.org/585274
-
---- tiff-4.0.6/man/Makefile.am
-+++ tiff-4.0.6/man/Makefile.am
-@@ -27,7 +27,6 @@
- 	bmp2tiff.1 \
- 	fax2ps.1 \
- 	fax2tiff.1 \
--	gif2tiff.1 \
- 	pal2rgb.1 \
- 	ppm2tiff.1 \
- 	ras2tiff.1 \
---- tiff-4.0.6/test/Makefile.am
-+++ tiff-4.0.6/test/Makefile.am
-@@ -68,7 +68,6 @@
- TESTSCRIPTS = \
- 	bmp2tiff_palette.sh \
- 	bmp2tiff_rgb.sh \
--	gif2tiff.sh \
- 	ppm2tiff_pbm.sh \
- 	ppm2tiff_pgm.sh \
- 	ppm2tiff_ppm.sh \
---- tiff-4.0.6/tools/Makefile.am
-+++ tiff-4.0.6/tools/Makefile.am
-@@ -34,7 +34,6 @@
- 	bmp2tiff \
- 	fax2ps \
- 	fax2tiff \
--	gif2tiff \
- 	pal2rgb \
- 	ppm2tiff \
- 	ras2tiff \
-@@ -73,9 +72,6 @@
- fax2tiff_SOURCES = fax2tiff.c
- fax2tiff_LDADD = $(LIBTIFF) $(LIBPORT)
- 
--gif2tiff_SOURCES = gif2tiff.c
--gif2tiff_LDADD = $(LIBTIFF) $(LIBPORT)
--
- pal2rgb_SOURCES = pal2rgb.c
- pal2rgb_LDADD = $(LIBTIFF) $(LIBPORT)
- 

diff --git a/media-libs/tiff/tiff-4.0.6-r1.ebuild b/media-libs/tiff/tiff-4.0.6-r1.ebuild
deleted file mode 100644
index 7ae3d8b1033..00000000000
--- a/media-libs/tiff/tiff-4.0.6-r1.ebuild
+++ /dev/null
@@ -1,73 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=6
-inherit autotools eutils libtool multilib-minimal
-
-DESCRIPTION="Tag Image File Format (TIFF) library"
-HOMEPAGE="http://libtiff.maptools.org"
-SRC_URI="http://download.osgeo.org/libtiff/${P}.tar.gz
-	ftp://ftp.remotesensing.org/pub/libtiff/${P}.tar.gz"
-
-LICENSE="libtiff"
-SLOT="0"
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~x64-solaris ~x86-solaris"
-IUSE="+cxx jbig jpeg lzma static-libs test zlib"
-
-RDEPEND="jpeg? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
-	jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
-	lzma? ( >=app-arch/xz-utils-5.0.5-r1:=[${MULTILIB_USEDEP}] )
-	zlib? ( >=sys-libs/zlib-1.2.8-r1:=[${MULTILIB_USEDEP}] )
-	abi_x86_32? (
-		!<=app-emulation/emul-linux-x86-baselibs-20130224-r9
-		!app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
-	)"
-DEPEND="${RDEPEND}"
-
-REQUIRED_USE="test? ( jpeg )" #483132
-
-MULTILIB_WRAPPED_HEADERS=(
-	/usr/include/tiffconf.h
-)
-
-PATCHES=(
-	"${FILESDIR}/${P}-gif2tiff_removal.patch" # 585274
-)
-
-src_prepare() {
-	default
-	eautoreconf
-}
-
-multilib_src_configure() {
-	ECONF_SOURCE="${S}" econf \
-		$(use_enable static-libs static) \
-		$(use_enable zlib) \
-		$(use_enable jpeg) \
-		$(use_enable jbig) \
-		$(use_enable lzma) \
-		$(use_enable cxx) \
-		--without-x
-
-	# remove useless subdirs
-	if ! multilib_is_native_abi ; then
-		sed -i \
-			-e 's/ tools//' \
-			-e 's/ contrib//' \
-			-e 's/ man//' \
-			-e 's/ html//' \
-			Makefile || die
-	fi
-}
-
-multilib_src_test() {
-	if ! multilib_is_native_abi ; then
-		emake -C tools
-	fi
-	emake check
-}
-
-multilib_src_install_all() {
-	prune_libtool_files --all
-	rm -f "${ED}"/usr/share/doc/${PF}/{COPYRIGHT,README*,RELEASE-DATE,TODO,VERSION}
-}

diff --git a/media-libs/tiff/tiff-4.0.6.ebuild b/media-libs/tiff/tiff-4.0.6.ebuild
deleted file mode 100644
index 5864109d05c..00000000000
--- a/media-libs/tiff/tiff-4.0.6.ebuild
+++ /dev/null
@@ -1,69 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=5
-inherit eutils libtool multilib-minimal
-
-DESCRIPTION="Tag Image File Format (TIFF) library"
-HOMEPAGE="http://libtiff.maptools.org"
-SRC_URI="http://download.osgeo.org/libtiff/${P}.tar.gz
-	ftp://ftp.remotesensing.org/pub/libtiff/${P}.tar.gz"
-
-LICENSE="libtiff"
-SLOT="0"
-KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~m68k ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~x64-solaris ~x86-solaris"
-IUSE="+cxx jbig jpeg lzma static-libs test zlib"
-
-RDEPEND="jpeg? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
-	jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
-	lzma? ( >=app-arch/xz-utils-5.0.5-r1:=[${MULTILIB_USEDEP}] )
-	zlib? ( >=sys-libs/zlib-1.2.8-r1:=[${MULTILIB_USEDEP}] )
-	abi_x86_32? (
-		!<=app-emulation/emul-linux-x86-baselibs-20130224-r9
-		!app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
-	)"
-DEPEND="${RDEPEND}"
-
-REQUIRED_USE="test? ( jpeg )" #483132
-
-MULTILIB_WRAPPED_HEADERS=(
-	/usr/include/tiffconf.h
-)
-
-src_prepare() {
-	elibtoolize
-}
-
-multilib_src_configure() {
-	ECONF_SOURCE="${S}" econf \
-		$(use_enable static-libs static) \
-		$(use_enable zlib) \
-		$(use_enable jpeg) \
-		$(use_enable jbig) \
-		$(use_enable lzma) \
-		$(use_enable cxx) \
-		--without-x \
-		--with-docdir="${EPREFIX}"/usr/share/doc/${PF}
-
-	# remove useless subdirs
-	if ! multilib_is_native_abi ; then
-		sed -i \
-			-e 's/ tools//' \
-			-e 's/ contrib//' \
-			-e 's/ man//' \
-			-e 's/ html//' \
-			Makefile || die
-	fi
-}
-
-multilib_src_test() {
-	if ! multilib_is_native_abi ; then
-		emake -C tools
-	fi
-	emake check
-}
-
-multilib_src_install_all() {
-	prune_libtool_files --all
-	rm -f "${ED}"/usr/share/doc/${PF}/{COPYRIGHT,README*,RELEASE-DATE,TODO,VERSION}
-}

diff --git a/media-libs/tiff/tiff-4.0.7-r1.ebuild b/media-libs/tiff/tiff-4.0.7-r1.ebuild
deleted file mode 100644
index dbf9257f2cc..00000000000
--- a/media-libs/tiff/tiff-4.0.7-r1.ebuild
+++ /dev/null
@@ -1,113 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-inherit autotools eutils libtool multilib-minimal
-
-DESCRIPTION="Tag Image File Format (TIFF) library"
-HOMEPAGE="http://libtiff.maptools.org"
-SRC_URI="http://download.osgeo.org/libtiff/${P}.tar.gz
-	ftp://ftp.remotesensing.org/pub/libtiff/${P}.tar.gz"
-
-LICENSE="libtiff"
-SLOT="0"
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x64-cygwin ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~x64-solaris ~x86-solaris"
-IUSE="+cxx jbig jpeg lzma static-libs test zlib"
-
-RDEPEND="jpeg? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
-	jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
-	lzma? ( >=app-arch/xz-utils-5.0.5-r1:=[${MULTILIB_USEDEP}] )
-	zlib? ( >=sys-libs/zlib-1.2.8-r1:=[${MULTILIB_USEDEP}] )
-	abi_x86_32? (
-		!<=app-emulation/emul-linux-x86-baselibs-20130224-r9
-		!app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
-	)"
-DEPEND="${RDEPEND}"
-
-REQUIRED_USE="test? ( jpeg )" #483132
-
-PATCHES=(
-	"${FILESDIR}"/${P}-fax2tiff.patch #598938
-	"${FILESDIR}"/${P}-CVE-2016-10266.patch
-	"${FILESDIR}"/${P}-bug2598.patch
-	"${FILESDIR}"/${P}-bug2604.patch
-	"${FILESDIR}"/${P}-bug2608.patch
-	"${FILESDIR}"/${P}-CVE-2016-10267.patch
-	"${FILESDIR}"/${P}-bug2620.patch
-	"${FILESDIR}"/${P}-bug2621.patch
-	"${FILESDIR}"/${P}-bug2619.patch
-	"${FILESDIR}"/${P}-bug2594.patch
-	"${FILESDIR}"/${P}-bug2597.patch
-	"${FILESDIR}"/${P}-bug2599.patch
-	"${FILESDIR}"/${P}-bug2607.patch
-	"${FILESDIR}"/${P}-bug2610.patch
-	"${FILESDIR}"/${P}-bug2605.patch
-	"${FILESDIR}"/${P}-hylafax-hack.patch #612172
-	"${FILESDIR}"/${P}-bug2633-bug2634.patch
-	"${FILESDIR}"/${P}-bug2635.patch
-	"${FILESDIR}"/${P}-bug2627.patch
-	"${FILESDIR}"/${P}-bug2638.patch
-	"${FILESDIR}"/${P}-bug2639.patch
-	"${FILESDIR}"/${P}-bug2640.patch
-	"${FILESDIR}"/${P}-bug2653.patch
-	"${FILESDIR}"/${P}-bug2535.patch
-	"${FILESDIR}"/${P}-bug2644.patch
-	"${FILESDIR}"/${P}-bug2642-bug2643-bug2646-bug2647.patch
-	"${FILESDIR}"/${P}-bug2648.patch
-	"${FILESDIR}"/${P}-bug2650.patch
-	"${FILESDIR}"/${P}-bug2658.patch
-	"${FILESDIR}"/${P}-bug2650-2.patch
-	"${FILESDIR}"/${P}-bug2651.patch
-	"${FILESDIR}"/${P}-CVE-2017-5225.patch #610330
-	"${FILESDIR}"/${P}-bug2130.patch
-	"${FILESDIR}"/${P}-bug2659.patch
-	"${FILESDIR}"/${P}-bug2659-2.patch
-	"${FILESDIR}"/${P}-bug2631.patch
-	"${FILESDIR}"/${P}-bug2665.patch
-)
-
-MULTILIB_WRAPPED_HEADERS=(
-	/usr/include/tiffconf.h
-)
-
-src_prepare() {
-	default
-
-	# tiffcp-thumbnail.sh fails as thumbnail binary doesn't get built anymore since tiff-4.0.7
-	sed '/tiffcp-thumbnail\.sh/d' -i test/Makefile.am || die
-
-	eautoreconf
-}
-
-multilib_src_configure() {
-	ECONF_SOURCE="${S}" econf \
-		$(use_enable static-libs static) \
-		$(use_enable zlib) \
-		$(use_enable jpeg) \
-		$(use_enable jbig) \
-		$(use_enable lzma) \
-		$(use_enable cxx) \
-		--without-x
-
-	# remove useless subdirs
-	if ! multilib_is_native_abi ; then
-		sed -i \
-			-e 's/ tools//' \
-			-e 's/ contrib//' \
-			-e 's/ man//' \
-			-e 's/ html//' \
-			Makefile || die
-	fi
-}
-
-multilib_src_test() {
-	if ! multilib_is_native_abi ; then
-		emake -C tools
-	fi
-	emake check
-}
-
-multilib_src_install_all() {
-	prune_libtool_files --all
-	rm -f "${ED}"/usr/share/doc/${PF}/{COPYRIGHT,README*,RELEASE-DATE,TODO,VERSION}
-}


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/
@ 2017-11-19 20:52 Lars Wendler
  0 siblings, 0 replies; 13+ messages in thread
From: Lars Wendler @ 2017-11-19 20:52 UTC (permalink / raw
  To: gentoo-commits

commit:     249ac401ff26eaed63135c2732186a1f98e13eb0
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 19 20:51:35 2017 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Sun Nov 19 20:52:26 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=249ac401

media-libs/tiff: Removed old.

Package-Manager: Portage-2.3.14, Repoman-2.3.6

 media-libs/tiff/Manifest                           |   1 -
 .../tiff/files/tiff-4.0.7-CVE-2016-10266.patch     |  46 ----
 .../tiff/files/tiff-4.0.7-CVE-2016-10267.patch     |  53 ----
 .../tiff/files/tiff-4.0.7-CVE-2017-5225.patch      |  74 ------
 media-libs/tiff/files/tiff-4.0.7-bug2130.patch     | 112 ---------
 media-libs/tiff/files/tiff-4.0.7-bug2535.patch     |  54 ----
 media-libs/tiff/files/tiff-4.0.7-bug2594.patch     |  28 ---
 media-libs/tiff/files/tiff-4.0.7-bug2597.patch     |  41 ---
 media-libs/tiff/files/tiff-4.0.7-bug2598.patch     |  31 ---
 media-libs/tiff/files/tiff-4.0.7-bug2599.patch     |  54 ----
 media-libs/tiff/files/tiff-4.0.7-bug2604.patch     | 108 --------
 media-libs/tiff/files/tiff-4.0.7-bug2605.patch     |  55 ----
 media-libs/tiff/files/tiff-4.0.7-bug2607.patch     |  41 ---
 media-libs/tiff/files/tiff-4.0.7-bug2608.patch     | 104 --------
 media-libs/tiff/files/tiff-4.0.7-bug2610.patch     |  46 ----
 media-libs/tiff/files/tiff-4.0.7-bug2619.patch     |  46 ----
 media-libs/tiff/files/tiff-4.0.7-bug2620.patch     |  29 ---
 media-libs/tiff/files/tiff-4.0.7-bug2621.patch     |  49 ----
 media-libs/tiff/files/tiff-4.0.7-bug2627.patch     |  59 -----
 media-libs/tiff/files/tiff-4.0.7-bug2631.patch     |  34 ---
 .../tiff/files/tiff-4.0.7-bug2633-bug2634.patch    |  41 ---
 media-libs/tiff/files/tiff-4.0.7-bug2635.patch     |  33 ---
 media-libs/tiff/files/tiff-4.0.7-bug2638.patch     |  29 ---
 media-libs/tiff/files/tiff-4.0.7-bug2639.patch     |  58 -----
 media-libs/tiff/files/tiff-4.0.7-bug2640.patch     |  28 ---
 ...iff-4.0.7-bug2642-bug2643-bug2646-bug2647.patch | 278 ---------------------
 media-libs/tiff/files/tiff-4.0.7-bug2644.patch     |  45 ----
 media-libs/tiff/files/tiff-4.0.7-bug2648.patch     |  33 ---
 media-libs/tiff/files/tiff-4.0.7-bug2650-2.patch   |  26 --
 media-libs/tiff/files/tiff-4.0.7-bug2650.patch     |  54 ----
 media-libs/tiff/files/tiff-4.0.7-bug2651.patch     |  86 -------
 media-libs/tiff/files/tiff-4.0.7-bug2653.patch     |  33 ---
 media-libs/tiff/files/tiff-4.0.7-bug2658.patch     |  33 ---
 media-libs/tiff/files/tiff-4.0.7-bug2659-2.patch   |  41 ---
 media-libs/tiff/files/tiff-4.0.7-bug2659.patch     |  34 ---
 media-libs/tiff/files/tiff-4.0.7-bug2665.patch     |  43 ----
 media-libs/tiff/files/tiff-4.0.7-fax2tiff.patch    |  39 ---
 .../tiff/files/tiff-4.0.7-hylafax-hack.patch       |  38 ---
 media-libs/tiff/tiff-4.0.7-r3.ebuild               | 121 ---------
 media-libs/tiff/tiff-4.0.7.ebuild                  |  73 ------
 40 files changed, 2231 deletions(-)

diff --git a/media-libs/tiff/Manifest b/media-libs/tiff/Manifest
index bee82d59f00..2b2df775d4e 100644
--- a/media-libs/tiff/Manifest
+++ b/media-libs/tiff/Manifest
@@ -1,4 +1,3 @@
 DIST tiff-3.9.7.tar.gz 1468097 SHA256 f5d64dd4ce61c55f5e9f6dc3920fbe5a41e02c2e607da7117a35eb5c320cef6a SHA512 ca89584a9ffa33b4986e4bc2165043cec239896f1f0ab73db00818d0442b570efaa6345b2ed422e884202324d359713df849bf14782bb0cf3b959655febddd77 WHIRLPOOL c06b35da66c365c1fe7f0e6e06a400e139d3e2b5b280aa764015c2f0383a6191ffb3d335cdf2211b687bbb0caacf641be409148986a9813dfde5822a650a9b1c
-DIST tiff-4.0.7.tar.gz 2076392 SHA256 9f43a2cfb9589e5cecaa66e16bf87f814c945f22df7ba600d63aac4632c4f019 SHA512 941357bdd5f947cdca41a1d31ae14b3fadc174ae5dce7b7981dbe58f61995f575ac2e97a7cc4fcc435184012017bec0920278263490464644f2cdfad9a6c5ddc WHIRLPOOL 3090a0d8a5ad3595c97888edab3c48379175cad993567d20be5f397b1c5c1d21012de55c5da5e664ee483d294fe9eb5f3464e14f564fb79c1357094ff67e313d
 DIST tiff-4.0.8.tar.gz 2065574 SHA256 59d7a5a8ccd92059913f246877db95a2918e6c04fb9d43fd74e5c3390dac2910 SHA512 5d010ec4ce37aca733f7ab7db9f432987b0cd21664bd9d99452a146833c40f0d1e7309d1870b0395e947964134d5cfeb1366181e761fe353ad585803ff3d6be6 WHIRLPOOL 13fce447c586fef080c6201f0f5b010bc8b0e096bc9b806ab3b80eb6a672c789f88b5fc34a51585aa7072bb8407ecc958d1d7824fad379f86968f051de2fa96d
 DIST tiff-4.0.9.tar.gz 2305681 SHA256 6e7bdeec2c310734e734d19aae3a71ebe37a4d842e0e23dbb1b8921c0026cfcd SHA512 04f3d5eefccf9c1a0393659fe27f3dddd31108c401ba0dc587bca152a1c1f6bc844ba41622ff5572da8cc278593eff8c402b44e7af0a0090e91d326c2d79f6cd WHIRLPOOL e67378d8d7c17d892e5f075d4e13aa299042a9f989fd6051b23d986518a11f2bbbcb13f491d87da6e6455aa28df2cce0fb65761237e256ac2e37889272f2ddf7

diff --git a/media-libs/tiff/files/tiff-4.0.7-CVE-2016-10266.patch b/media-libs/tiff/files/tiff-4.0.7-CVE-2016-10266.patch
deleted file mode 100644
index 67e0ca41c99..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-CVE-2016-10266.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-http://bugzilla.maptools.org/show_bug.cgi?id=2596
-
-From d7520d28685b96a28421ef01fb66cea8d1a96dfc Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-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
-
----
- ChangeLog          | 7 +++++++
- libtiff/tif_read.c | 4 ++--
- libtiff/tiffiop.h  | 6 +++++-
- 3 files changed, 14 insertions(+), 3 deletions(-)
-
-diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c
-index 80035929f033..29a311db0cb7 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 8bcd0c172c08..5294ee78ffaf 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.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-CVE-2016-10267.patch b/media-libs/tiff/files/tiff-4.0.7-CVE-2016-10267.patch
deleted file mode 100644
index 04d9729ff73..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-CVE-2016-10267.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-http://bugzilla.maptools.org/show_bug.cgi?id=2611
-
-From bd06f6c97dff0b30de0f80227d782ea448c14b19 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-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
-
----
- ChangeLog           |  7 +++++++
- libtiff/tif_ojpeg.c | 10 +++++++++-
- 2 files changed, 16 insertions(+), 1 deletion(-)
-
-diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c
-index 30a1812634e0..93839d8f3e11 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.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-CVE-2017-5225.patch b/media-libs/tiff/files/tiff-4.0.7-CVE-2017-5225.patch
deleted file mode 100644
index 7f961474ba9..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-CVE-2017-5225.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-https://bugs.gentoo.org/610330
-
-From 24bc05876f5a1a300a3c4eb0fa8e8cea6a256f9f Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Wed, 11 Jan 2017 19:25:44 +0000
-Subject: [PATCH] * tools/tiffcp.c: error out cleanly in cpContig2SeparateByRow
- and cpSeparate2ContigByRow if BitsPerSample != 8 to avoid heap based
- overflow. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2656 and
- http://bugzilla.maptools.org/show_bug.cgi?id=2657
-
----
- ChangeLog      |  7 +++++++
- tools/tiffcp.c | 26 +++++++++++++++++++++++---
- 2 files changed, 30 insertions(+), 3 deletions(-)
-
-diff --git a/tools/tiffcp.c b/tools/tiffcp.c
-index 49c9d37125a6..489459a7f6a4 100644
---- a/tools/tiffcp.c
-+++ b/tools/tiffcp.c
-@@ -591,7 +591,7 @@ static	copyFunc pickCopyFunc(TIFF*, TIFF*, uint16, uint16);
- static int
- tiffcp(TIFF* in, TIFF* out)
- {
--	uint16 bitspersample, samplesperpixel = 1;
-+	uint16 bitspersample = 1, samplesperpixel = 1;
- 	uint16 input_compression, input_photometric = PHOTOMETRIC_MINISBLACK;
- 	copyFunc cf;
- 	uint32 width, length;
-@@ -1067,6 +1067,16 @@ DECLAREcpFunc(cpContig2SeparateByRow)
- 	register uint32 n;
- 	uint32 row;
- 	tsample_t s;
-+        uint16 bps = 0;
-+
-+        (void) TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps);
-+        if( bps != 8 )
-+        {
-+            TIFFError(TIFFFileName(in),
-+                      "Error, can only handle BitsPerSample=8 in %s",
-+                      "cpContig2SeparateByRow");
-+            return 0;
-+        }
- 
- 	inbuf = _TIFFmalloc(scanlinesizein);
- 	outbuf = _TIFFmalloc(scanlinesizeout);
-@@ -1120,6 +1130,16 @@ DECLAREcpFunc(cpSeparate2ContigByRow)
- 	register uint32 n;
- 	uint32 row;
- 	tsample_t s;
-+        uint16 bps = 0;
-+
-+        (void) TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps);
-+        if( bps != 8 )
-+        {
-+            TIFFError(TIFFFileName(in),
-+                      "Error, can only handle BitsPerSample=8 in %s",
-+                      "cpSeparate2ContigByRow");
-+            return 0;
-+        }
- 
- 	inbuf = _TIFFmalloc(scanlinesizein);
- 	outbuf = _TIFFmalloc(scanlinesizeout);
-@@ -1784,7 +1804,7 @@ pickCopyFunc(TIFF* in, TIFF* out, uint16 bitspersample, uint16 samplesperpixel)
- 	uint32 w, l, tw, tl;
- 	int bychunk;
- 
--	(void) TIFFGetField(in, TIFFTAG_PLANARCONFIG, &shortv);
-+	(void) TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &shortv);
- 	if (shortv != config && bitspersample != 8 && samplesperpixel > 1) {
- 		fprintf(stderr,
- 		    "%s: Cannot handle different planar configuration w/ bits/sample != 8\n",
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2130.patch b/media-libs/tiff/files/tiff-4.0.7-bug2130.patch
deleted file mode 100644
index b565fecc029..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2130.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From c2faaeaa7887c24c574297e8e2f36208df9dc229 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Wed, 11 Jan 2017 20:33:35 +0000
-Subject: [PATCH] * libtiff/tif_luv.c, tif_lzw.c, tif_packbits.c: return 0 in
- Encode functions instead of -1 when TIFFFlushData1() fails. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2130
-
----
- ChangeLog              |  6 ++++++
- libtiff/tif_luv.c      | 12 ++++++------
- libtiff/tif_lzw.c      |  8 +++++---
- libtiff/tif_packbits.c |  6 +++---
- 4 files changed, 20 insertions(+), 12 deletions(-)
-
-diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c
-index f42ac0131fee..1f6d8ba3ea5a 100644
---- a/libtiff/tif_luv.c
-+++ b/libtiff/tif_luv.c
-@@ -473,7 +473,7 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
- 				tif->tif_rawcp = op;
- 				tif->tif_rawcc = tif->tif_rawdatasize - occ;
- 				if (!TIFFFlushData1(tif))
--					return (-1);
-+					return (0);
- 				op = tif->tif_rawcp;
- 				occ = tif->tif_rawdatasize - tif->tif_rawcc;
- 			}
-@@ -505,7 +505,7 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
- 					tif->tif_rawcp = op;
- 					tif->tif_rawcc = tif->tif_rawdatasize - occ;
- 					if (!TIFFFlushData1(tif))
--						return (-1);
-+						return (0);
- 					op = tif->tif_rawcp;
- 					occ = tif->tif_rawdatasize - tif->tif_rawcc;
- 				}
-@@ -565,7 +565,7 @@ LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
- 			tif->tif_rawcp = op;
- 			tif->tif_rawcc = tif->tif_rawdatasize - occ;
- 			if (!TIFFFlushData1(tif))
--				return (-1);
-+				return (0);
- 			op = tif->tif_rawcp;
- 			occ = tif->tif_rawdatasize - tif->tif_rawcc;
- 		}
-@@ -624,7 +624,7 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
- 				tif->tif_rawcp = op;
- 				tif->tif_rawcc = tif->tif_rawdatasize - occ;
- 				if (!TIFFFlushData1(tif))
--					return (-1);
-+					return (0);
- 				op = tif->tif_rawcp;
- 				occ = tif->tif_rawdatasize - tif->tif_rawcc;
- 			}
-@@ -656,7 +656,7 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
- 					tif->tif_rawcp = op;
- 					tif->tif_rawcc = tif->tif_rawdatasize - occ;
- 					if (!TIFFFlushData1(tif))
--						return (-1);
-+						return (0);
- 					op = tif->tif_rawcp;
- 					occ = tif->tif_rawdatasize - tif->tif_rawcc;
- 				}
-diff --git a/libtiff/tif_lzw.c b/libtiff/tif_lzw.c
-index 240e19c2e058..5ba35ec1305f 100644
---- a/libtiff/tif_lzw.c
-+++ b/libtiff/tif_lzw.c
-@@ -969,7 +969,8 @@ LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
- 		 */
- 		if (op > limit) {
- 			tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata);
--			TIFFFlushData1(tif);
-+			if( !TIFFFlushData1(tif) )
-+                            return 0;
- 			op = tif->tif_rawdata;
- 		}
- 		PutNextCode(op, ent);
-@@ -1054,7 +1055,8 @@ LZWPostEncode(TIFF* tif)
- 
- 	if (op > sp->enc_rawlimit) {
- 		tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata);
--		TIFFFlushData1(tif);
-+		if( !TIFFFlushData1(tif) )
-+                    return 0;
- 		op = tif->tif_rawdata;
- 	}
- 	if (sp->enc_oldcode != (hcode_t) -1) {
-diff --git a/libtiff/tif_packbits.c b/libtiff/tif_packbits.c
-index d2a0165de9dd..0495e688a6be 100644
---- a/libtiff/tif_packbits.c
-+++ b/libtiff/tif_packbits.c
-@@ -99,7 +99,7 @@ PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
- 				slop = (long)(op - lastliteral);
- 				tif->tif_rawcc += (tmsize_t)(lastliteral - tif->tif_rawcp);
- 				if (!TIFFFlushData1(tif))
--					return (-1);
-+					return (0);
- 				op = tif->tif_rawcp;
- 				while (slop-- > 0)
- 					*op++ = *lastliteral++;
-@@ -107,7 +107,7 @@ PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
- 			} else {
- 				tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp);
- 				if (!TIFFFlushData1(tif))
--					return (-1);
-+					return (0);
- 				op = tif->tif_rawcp;
- 			}
- 		}
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2535.patch b/media-libs/tiff/files/tiff-4.0.7-bug2535.patch
deleted file mode 100644
index c44a8f05d20..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2535.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From c4e376852d82936885833441169684267983691f Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Wed, 11 Jan 2017 12:51:59 +0000
-Subject: [PATCH] * libtiff/tif_dirwrite.c: in
- TIFFWriteDirectoryTagCheckedRational, replace assertion by runtime check to
- error out if passed value is strictly negative. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2535
-
-* tools/tiffcrop.c: remove extraneous TIFFClose() in error code path, that
-caused double free.
-Related to http://bugzilla.maptools.org/show_bug.cgi?id=2535
----
- ChangeLog              | 11 +++++++++++
- libtiff/tif_dirwrite.c | 11 ++++++++---
- tools/tiffcrop.c       |  3 +--
- 3 files changed, 20 insertions(+), 5 deletions(-)
-
-diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
-index d34f6f611d39..055324db078f 100644
---- a/libtiff/tif_dirwrite.c
-+++ b/libtiff/tif_dirwrite.c
-@@ -2094,10 +2094,15 @@ TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* d
- static int
- TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value)
- {
-+        static const char module[] = "TIFFWriteDirectoryTagCheckedRational";
- 	uint32 m[2];
--	assert(value>=0.0);
- 	assert(sizeof(uint32)==4);
--	if (value<=0.0)
-+        if( value < 0 )
-+        {
-+            TIFFErrorExt(tif->tif_clientdata,module,"Negative value is illegal");
-+            return 0;
-+        }
-+	else if (value==0.0)
- 	{
- 		m[0]=0;
- 		m[1]=1;
-diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
-index 21dd08720d77..c69177e052d4 100644
---- a/tools/tiffcrop.c
-+++ b/tools/tiffcrop.c
-@@ -7996,7 +7996,6 @@ writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image,
-   if (!TIFFWriteDirectory(out))
-     {
-     TIFFError("","Failed to write IFD for page number %d", pagenum);
--    TIFFClose(out);
-     return (-1);
-     }
- 
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2594.patch b/media-libs/tiff/files/tiff-4.0.7-bug2594.patch
deleted file mode 100644
index b2bc26e9064..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2594.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From a56820e2022e23610c1ea99fbf621d73d1e36348 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Sat, 3 Dec 2016 14:18:48 +0000
-Subject: [PATCH] * tools/tiffinfo.c: fix null pointer dereference in -r mode
- when the image has no StripByteCount tag. Reported by Agostino Sarubbo. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2594
-
----
- ChangeLog        | 7 +++++++
- tools/tiffinfo.c | 4 ++--
- 2 files changed, 9 insertions(+), 2 deletions(-)
-
-diff --git a/tools/tiffinfo.c b/tools/tiffinfo.c
-index b02c7d46bed0..4d58055de85c 100644
---- a/tools/tiffinfo.c
-+++ b/tools/tiffinfo.c
-@@ -417,7 +417,7 @@ TIFFReadRawData(TIFF* tif, int bitrev)
- 	uint64* stripbc=NULL;
- 
- 	TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbc);
--	if (nstrips > 0) {
-+	if (stripbc != NULL && nstrips > 0) {
- 		uint32 bufsize = (uint32) stripbc[0];
- 		tdata_t buf = _TIFFmalloc(bufsize);
- 		tstrip_t s;
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2597.patch b/media-libs/tiff/files/tiff-4.0.7-bug2597.patch
deleted file mode 100644
index 9cd29cfab77..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2597.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From 5ad5e64f8530a827482645986f5bb4e4613d0aa7 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Sat, 3 Dec 2016 14:42:40 +0000
-Subject: [PATCH] * tools/tiffcp.c: avoid potential division by zero is
- BitsPerSamples tag is missing. Reported by Agostino sarubbo. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2597
-
----
- ChangeLog      |  7 +++++++
- tools/tiffcp.c | 10 ++++++++--
- 2 files changed, 15 insertions(+), 2 deletions(-)
-
-diff --git a/tools/tiffcp.c b/tools/tiffcp.c
-index 6dfb9a91bfa9..c8e48c3c2bb3 100644
---- a/tools/tiffcp.c
-+++ b/tools/tiffcp.c
-@@ -1378,7 +1378,7 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
- 	uint8* bufp = (uint8*) buf;
- 	uint32 tw, tl;
- 	uint32 row;
--	uint16 bps, bytes_per_sample;
-+	uint16 bps = 0, bytes_per_sample;
- 
- 	tilebuf = _TIFFmalloc(tilesize);
- 	if (tilebuf == 0)
-@@ -1387,6 +1387,12 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
- 	(void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw);
- 	(void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl);
- 	(void) TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps);
-+        if( bps == 0 )
-+        {
-+            TIFFError(TIFFFileName(in), "Error, cannot read BitsPerSample");
-+            status = 0;
-+            goto done;
-+        }
- 	assert( bps % 8 == 0 );
- 	bytes_per_sample = bps/8;
- 
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2598.patch b/media-libs/tiff/files/tiff-4.0.7-bug2598.patch
deleted file mode 100644
index c0a0d1a8db1..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2598.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-http://bugzilla.maptools.org/show_bug.cgi?id=2598
-
-From bc3d7392e43545c7c6375897458a7a3e8ee4d9d8 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-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
-
----
- ChangeLog      | 7 +++++++
- tools/tiffcp.c | 4 ++--
- 2 files changed, 9 insertions(+), 2 deletions(-)
-
-diff --git a/tools/tiffcp.c b/tools/tiffcp.c
-index 338a3d113bf8..6dfb9a91bfa9 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.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2599.patch b/media-libs/tiff/files/tiff-4.0.7-bug2599.patch
deleted file mode 100644
index 929bb447bf7..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2599.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From 9bbbe303c8e5db20d7f687ee1ca19c98fb852044 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Sat, 3 Dec 2016 15:30:31 +0000
-Subject: [PATCH] * tools/tif_dir.c: when TIFFGetField(, TIFFTAG_NUMBEROFINKS,
- ) is called, limit the return number of inks to SamplesPerPixel, so that code
- that parses ink names doesn't go past the end of the buffer. Reported by
- Agostino Sarubbo. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2599
-
-Reported by Agostino Sarubbo.
----
- ChangeLog         | 10 +++++++++-
- libtiff/tif_dir.c | 28 +++++++++++++++++++++++++++-
- 2 files changed, 36 insertions(+), 2 deletions(-)
-
-diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c
-index ad21655a6ee9..2574e748b3be 100644
---- a/libtiff/tif_dir.c
-+++ b/libtiff/tif_dir.c
-@@ -854,6 +854,32 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
- 	if( fip == NULL ) /* cannot happen since TIFFGetField() already checks it */
- 	    return 0;
- 	
-+        if( tag == TIFFTAG_NUMBEROFINKS )
-+        {
-+            int i;
-+            for (i = 0; i < td->td_customValueCount; i++) {
-+                uint16 val;
-+                TIFFTagValue *tv = td->td_customValues + i;
-+                if (tv->info->field_tag != tag)
-+                    continue;
-+                val = *(uint16 *)tv->value;
-+                /* Truncate to SamplesPerPixel, since the */
-+                /* setting code for INKNAMES assume that there are SamplesPerPixel */
-+                /* inknames. */
-+                /* Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2599 */
-+                if( val > td->td_samplesperpixel )
-+                {
-+                    TIFFWarningExt(tif->tif_clientdata,"_TIFFVGetField",
-+                                   "Truncating NumberOfInks from %u to %u",
-+                                   val, td->td_samplesperpixel);
-+                    val = td->td_samplesperpixel;
-+                }
-+                *va_arg(ap, uint16*) = val;
-+                return 1;
-+            }
-+            return 0;
-+        }
-+
- 	/*
- 	 * We want to force the custom code to be used for custom
- 	 * fields even if the tag happens to match a well known 
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2604.patch b/media-libs/tiff/files/tiff-4.0.7-bug2604.patch
deleted file mode 100644
index cc3f4cf3ce9..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2604.patch
+++ /dev/null
@@ -1,108 +0,0 @@
-From ebc6029128555df725e6ad77a983134350bfc831 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-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
-
----
- ChangeLog              | 10 ++++++++++
- libtiff/tif_luv.c      | 20 +++++++++++++++-----
- libtiff/tif_pixarlog.c | 19 ++++++++++++++++---
- 3 files changed, 41 insertions(+), 8 deletions(-)
-
-diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c
-index ca08f30a76b6..f42ac0131fee 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 f4af2bab7ce5..9836dce63450 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.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2605.patch b/media-libs/tiff/files/tiff-4.0.7-bug2605.patch
deleted file mode 100644
index 335e4348d3f..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2605.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-From cd4832257daf222833ae172b3923268fec5b71b9 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Sat, 3 Dec 2016 16:50:02 +0000
-Subject: [PATCH] * tools/tiffcp.c: replace assert( (bps % 8) == 0 ) by a non
- assert check. Reported by Agostino Sarubbo. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2605
-
----
- ChangeLog      |  6 ++++++
- tools/tiffcp.c | 17 +++++++++++++----
- 2 files changed, 19 insertions(+), 4 deletions(-)
-
-diff --git a/tools/tiffcp.c b/tools/tiffcp.c
-index 6d96bb89f555..49c9d37125a6 100644
---- a/tools/tiffcp.c
-+++ b/tools/tiffcp.c
-@@ -45,7 +45,6 @@
- #include <string.h>
- 
- #include <ctype.h>
--#include <assert.h>
- 
- #ifdef HAVE_UNISTD_H
- # include <unistd.h>
-@@ -1393,7 +1392,12 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
-             status = 0;
-             goto done;
-         }
--	assert( bps % 8 == 0 );
-+        if( (bps % 8) != 0 )
-+        {
-+            TIFFError(TIFFFileName(in), "Error, cannot handle BitsPerSample that is not a multiple of 8");
-+            status = 0;
-+            goto done;
-+        }
- 	bytes_per_sample = bps/8;
- 
- 	for (row = 0; row < imagelength; row += tl) {
-@@ -1584,7 +1588,12 @@ DECLAREwriteFunc(writeBufferToSeparateTiles)
-             _TIFFfree(obuf);
-             return 0;
-         }
--	assert( bps % 8 == 0 );
-+        if( (bps % 8) != 0 )
-+        {
-+            TIFFError(TIFFFileName(out), "Error, cannot handle BitsPerSample that is not a multiple of 8");
-+            _TIFFfree(obuf);
-+            return 0;
-+        }
- 	bytes_per_sample = bps/8;
- 
- 	for (row = 0; row < imagelength; row += tl) {
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2607.patch b/media-libs/tiff/files/tiff-4.0.7-bug2607.patch
deleted file mode 100644
index 532259e91cb..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2607.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From c99f44478d6f0491da5b98c8cea14f565a021e22 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Sat, 3 Dec 2016 15:44:15 +0000
-Subject: [PATCH] * tools/tiffcp.c: avoid potential division by zero is
- BitsPerSamples tag is missing. Reported by Agostino Sarubbo. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2607
-
----
- ChangeLog      |  7 +++++++
- tools/tiffcp.c | 10 ++++++++--
- 2 files changed, 15 insertions(+), 2 deletions(-)
-
-diff --git a/tools/tiffcp.c b/tools/tiffcp.c
-index c8e48c3c2bb3..142cbb0ecfc2 100644
---- a/tools/tiffcp.c
-+++ b/tools/tiffcp.c
-@@ -1569,7 +1569,7 @@ DECLAREwriteFunc(writeBufferToSeparateTiles)
- 	uint8* bufp = (uint8*) buf;
- 	uint32 tl, tw;
- 	uint32 row;
--	uint16 bps, bytes_per_sample;
-+	uint16 bps = 0, bytes_per_sample;
- 
- 	obuf = _TIFFmalloc(TIFFTileSize(out));
- 	if (obuf == NULL)
-@@ -1578,6 +1578,12 @@ DECLAREwriteFunc(writeBufferToSeparateTiles)
- 	(void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl);
- 	(void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw);
- 	(void) TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps);
-+        if( bps == 0 )
-+        {
-+            TIFFError(TIFFFileName(out), "Error, cannot read BitsPerSample");
-+            _TIFFfree(obuf);
-+            return 0;
-+        }
- 	assert( bps % 8 == 0 );
- 	bytes_per_sample = bps/8;
- 
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2608.patch b/media-libs/tiff/files/tiff-4.0.7-bug2608.patch
deleted file mode 100644
index afe2c25a293..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2608.patch
+++ /dev/null
@@ -1,104 +0,0 @@
-From 92adbddc283782d71d81dbccf72ed2c279f90097 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-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.
----
- ChangeLog             | 15 +++++++++++++++
- libtiff/tif_dirread.c | 24 +++++++++++-------------
- libtiff/tif_strip.c   | 11 +----------
- 3 files changed, 27 insertions(+), 23 deletions(-)
-
-diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
-index 01070f2ecebd..f2905286c0d0 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 b6098dd31241..6e9f2ef6ddf2 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.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2610.patch b/media-libs/tiff/files/tiff-4.0.7-bug2610.patch
deleted file mode 100644
index f76e83922d6..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2610.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From ee00edfbe833647d59ad87cac82f1b4c0c902179 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Sat, 3 Dec 2016 16:40:01 +0000
-Subject: [PATCH] * tools/tiffcp.c: fix uint32 underflow/overflow that can
- cause heap-based buffer overflow. Reported by Agostino Sarubbo. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2610
-
----
- ChangeLog      | 7 +++++++
- tools/tiffcp.c | 8 ++++----
- 2 files changed, 11 insertions(+), 4 deletions(-)
-
-diff --git a/tools/tiffcp.c b/tools/tiffcp.c
-index 142cbb0ecfc2..6d96bb89f555 100644
---- a/tools/tiffcp.c
-+++ b/tools/tiffcp.c
-@@ -1163,7 +1163,7 @@ bad:
- 
- static void
- cpStripToTile(uint8* out, uint8* in,
--    uint32 rows, uint32 cols, int outskew, int inskew)
-+    uint32 rows, uint32 cols, int outskew, int64 inskew)
- {
- 	while (rows-- > 0) {
- 		uint32 j = cols;
-@@ -1320,7 +1320,7 @@ DECLAREreadFunc(readContigTilesIntoBuffer)
- 	tdata_t tilebuf;
- 	uint32 imagew = TIFFScanlineSize(in);
- 	uint32 tilew  = TIFFTileRowSize(in);
--	int iskew = imagew - tilew;
-+	int64 iskew = (int64)imagew - (int64)tilew;
- 	uint8* bufp = (uint8*) buf;
- 	uint32 tw, tl;
- 	uint32 row;
-@@ -1348,7 +1348,7 @@ DECLAREreadFunc(readContigTilesIntoBuffer)
- 				status = 0;
- 				goto done;
- 			}
--			if (colb + tilew > imagew) {
-+			if (colb > iskew) {
- 				uint32 width = imagew - colb;
- 				uint32 oskew = tilew - width;
- 				cpStripToTile(bufp + colb,
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2619.patch b/media-libs/tiff/files/tiff-4.0.7-bug2619.patch
deleted file mode 100644
index 0e0053883a3..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2619.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From cb840651f037c59895b67d44b46a34127bb082dd Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Sat, 3 Dec 2016 13:00:03 +0000
-Subject: [PATCH] * tools/tiffcrop.c: fix integer division by zero when
- BitsPerSample is missing. Reported by Agostina Sarubo. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2619
-
----
- ChangeLog        | 6 ++++++
- tools/tiffcrop.c | 8 ++++----
- 2 files changed, 10 insertions(+), 4 deletions(-)
-
-diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
-index 9122aab37530..21dd08720d77 100644
---- a/tools/tiffcrop.c
-+++ b/tools/tiffcrop.c
-@@ -1164,7 +1164,7 @@ writeBufferToSeparateStrips (TIFF* out, uint8* buf,
-   tdata_t  obuf;
- 
-   (void) TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
--  (void) TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps);
-+  (void) TIFFGetFieldDefaulted(out, TIFFTAG_BITSPERSAMPLE, &bps);
-   bytes_per_sample = (bps + 7) / 8;
-   if( width == 0 ||
-       (uint32)bps * (uint32)spp > TIFF_UINT32_MAX / width ||
-@@ -4760,7 +4760,7 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8 *obuf, uint32 length,
-   int i, bytes_per_sample, bytes_per_pixel, shift_width, result = 1;
-   uint32 j;
-   int32  bytes_read = 0;
--  uint16 bps, planar;
-+  uint16 bps = 0, planar;
-   uint32 nstrips;
-   uint32 strips_per_sample;
-   uint32 src_rowsize, dst_rowsize, rows_processed, rps;
-@@ -4780,7 +4780,7 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8 *obuf, uint32 length,
-     }
- 
-   memset (srcbuffs, '\0', sizeof(srcbuffs));
--  TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps);
-+  TIFFGetFieldDefaulted(in, TIFFTAG_BITSPERSAMPLE, &bps);
-   TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &planar);
-   TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rps);
-   if (rps > length)
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2620.patch b/media-libs/tiff/files/tiff-4.0.7-bug2620.patch
deleted file mode 100644
index 1b37177c5f9..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2620.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 76c4b35f114bc9614700accd22cc4a0b4b6b92d3 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-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
-
----
- ChangeLog        | 7 +++++++
- tools/tiffcrop.c | 4 ++--
- 2 files changed, 9 insertions(+), 2 deletions(-)
-
-diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
-index 722b132cee6d..bdcbd63ed70b 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.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2621.patch b/media-libs/tiff/files/tiff-4.0.7-bug2621.patch
deleted file mode 100644
index 7bb1d57e3e9..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2621.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-From d7045ed1501ec99c4e56174813bb1cb5c9a559ef Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Sat, 3 Dec 2016 12:19:32 +0000
-Subject: [PATCH] * tools/tiffcrop.c: add 3 extra bytes at end of strip buffer
- in readSeparateStripsIntoBuffer() to avoid read outside of heap allocated
- buffer. Reported by Agostina Sarubo. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2621
-
----
- ChangeLog        |  7 +++++++
- tools/tiffcrop.c | 14 ++++++++++++--
- 2 files changed, 19 insertions(+), 2 deletions(-)
-
-diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
-index bdcbd63ed70b..9122aab37530 100644
---- a/tools/tiffcrop.c
-+++ b/tools/tiffcrop.c
-@@ -4815,10 +4815,17 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8 *obuf, uint32 length,
-   nstrips = TIFFNumberOfStrips(in);
-   strips_per_sample = nstrips /spp;
- 
-+  /* Add 3 padding bytes for combineSeparateSamples32bits */
-+  if( (size_t) stripsize > 0xFFFFFFFFU - 3U )
-+  {
-+      TIFFError("readSeparateStripsIntoBuffer", "Integer overflow when calculating buffer size.");
-+      exit(-1);
-+  }
-+
-   for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++)
-     {
-     srcbuffs[s] = NULL;
--    buff = _TIFFmalloc(stripsize);
-+    buff = _TIFFmalloc(stripsize + 3);
-     if (!buff)
-       {
-       TIFFError ("readSeparateStripsIntoBuffer", 
-@@ -4827,6 +4834,9 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8 *obuf, uint32 length,
-         _TIFFfree (srcbuffs[i]);
-       return 0;
-       }
-+    buff[stripsize] = 0;
-+    buff[stripsize+1] = 0;
-+    buff[stripsize+2] = 0;
-     srcbuffs[s] = buff;
-     }
- 
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2627.patch b/media-libs/tiff/files/tiff-4.0.7-bug2627.patch
deleted file mode 100644
index 11a3f3cd3f5..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2627.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From f88bfadb6d1fac1d0d081058216da659e1f5a628 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Sun, 18 Dec 2016 22:28:42 +0000
-Subject: [PATCH] * libtiff/tif_getimage.c: fix potential memory leaks in error
- code path of TIFFRGBAImageBegin(). Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2627
-
----
- ChangeLog              |  6 ++++++
- libtiff/tif_getimage.c | 21 +++++++++------------
- 2 files changed, 15 insertions(+), 12 deletions(-)
-
-diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c
-index c0eb6df0b09a..2ea838556732 100644
---- a/libtiff/tif_getimage.c
-+++ b/libtiff/tif_getimage.c
-@@ -283,6 +283,13 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
- 	img->redcmap = NULL;
- 	img->greencmap = NULL;
- 	img->bluecmap = NULL;
-+	img->Map = NULL;
-+	img->BWmap = NULL;
-+	img->PALmap = NULL;
-+	img->ycbcr = NULL;
-+	img->cielab = NULL;
-+	img->UaToAa = NULL;
-+	img->Bitdepth16To8 = NULL;
- 	img->req_orientation = ORIENTATION_BOTLEFT;     /* It is the default */
- 
- 	img->tif = tif;
-@@ -468,13 +475,6 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
- 			    photoTag, img->photometric);
-                         goto fail_return;
- 	}
--	img->Map = NULL;
--	img->BWmap = NULL;
--	img->PALmap = NULL;
--	img->ycbcr = NULL;
--	img->cielab = NULL;
--	img->UaToAa = NULL;
--	img->Bitdepth16To8 = NULL;
- 	TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width);
- 	TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height);
- 	TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation);
-@@ -494,10 +494,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
- 	return 1;
- 
-   fail_return:
--        _TIFFfree( img->redcmap );
--        _TIFFfree( img->greencmap );
--        _TIFFfree( img->bluecmap );
--        img->redcmap = img->greencmap = img->bluecmap = NULL;
-+        TIFFRGBAImageEnd( img );
-         return 0;
- }
- 
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2631.patch b/media-libs/tiff/files/tiff-4.0.7-bug2631.patch
deleted file mode 100644
index 6e1011b072d..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2631.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 101253c74cde97203dab28c4f3bd0994cea5804c Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Sat, 14 Jan 2017 13:12:33 +0000
-Subject: [PATCH] * tools/raw2tiff.c: avoid integer division by zero. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2631
-
----
- ChangeLog        |  5 +++++
- tools/raw2tiff.c | 10 ++++++++--
- 2 files changed, 13 insertions(+), 2 deletions(-)
-
-diff --git a/tools/raw2tiff.c b/tools/raw2tiff.c
-index 7298e80a95c9..083e9ee73f0f 100644
---- a/tools/raw2tiff.c
-+++ b/tools/raw2tiff.c
-@@ -408,8 +408,14 @@ guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, uint32 nbands,
- 	} else if (*width == 0 && *length == 0) {
-                 unsigned int fail = 0;
- 		fprintf(stderr,	"Image width and height are not specified.\n");
-+                w = (uint32) sqrt(imagesize / longt);
-+                if( w == 0 )
-+                {
-+                    fprintf(stderr, "Too small image size.\n");
-+                    return -1;
-+                }
- 
--		for (w = (uint32) sqrt(imagesize / longt);
-+		for (;
- 		     w < sqrt(imagesize * longt);
- 		     w++) {
- 			if (imagesize % w == 0) {
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2633-bug2634.patch b/media-libs/tiff/files/tiff-4.0.7-bug2633-bug2634.patch
deleted file mode 100644
index d68e86ebea2..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2633-bug2634.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From 95a32fbbadf54e7527c7e3b66fd603503b29dde9 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Sat, 17 Dec 2016 19:45:28 +0000
-Subject: [PATCH] * tools/tiff2ps.c: fix 2 heap-based buffer overflows (in
- PSDataBW and PSDataColorContig). Reported by Agostino Sarubbo. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2633 and
- http://bugzilla.maptools.org/show_bug.cgi?id=2634.
-
----
- ChangeLog       | 7 +++++++
- tools/tiff2ps.c | 9 +++++++--
- 2 files changed, 14 insertions(+), 2 deletions(-)
-
-diff --git a/tools/tiff2ps.c b/tools/tiff2ps.c
-index 82a5d84b41f5..71df4309ee0c 100644
---- a/tools/tiff2ps.c
-+++ b/tools/tiff2ps.c
-@@ -2440,6 +2440,11 @@ PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc)
- 	unsigned char *cp, c;
- 
- 	(void) w;
-+        if( es <= 0 )
-+        {
-+            TIFFError(filename, "Inconsistent value of es: %d", es);
-+            return;
-+        }
- 	tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow);
- 	if (tf_buf == NULL) {
- 		TIFFError(filename, "No space for scanline buffer");
-@@ -2692,7 +2697,7 @@ PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h)
- 
- 			if (alpha) {
- 				int adjust;
--				while (cc-- > 0) {
-+				while (cc-- > 1) {
- 					DOBREAK(breaklen, 1, fd);
- 					/*
- 					 * For images with alpha, matte against
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2635.patch b/media-libs/tiff/files/tiff-4.0.7-bug2635.patch
deleted file mode 100644
index 8756115c905..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2635.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From a7b470d67f2b98599b2c9cd9945db6eea735cc47 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Sun, 18 Dec 2016 10:37:59 +0000
-Subject: [PATCH] * tools/tiff2pdf.c: prevent heap-based buffer overflow in -j
- mode on a paletted image. Note: this fix errors out before the overflow
- happens. There could probably be a better fix. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2635
-
----
- ChangeLog        | 7 +++++++
- tools/tiff2pdf.c | 8 +++++++-
- 2 files changed, 14 insertions(+), 1 deletion(-)
-
-diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
-index fe8a6ea7e101..afea414bebf6 100644
---- a/tools/tiff2pdf.c
-+++ b/tools/tiff2pdf.c
-@@ -3654,6 +3654,12 @@ tsize_t t2p_sample_realize_palette(T2P* t2p, unsigned char* buffer){
- 	uint32 j=0;
- 	sample_count=t2p->tiff_width*t2p->tiff_length;
- 	component_count=t2p->tiff_samplesperpixel;
-+        if( sample_count * component_count > t2p->tiff_datasize )
-+        {
-+            TIFFError(TIFF2PDF_MODULE,  "Error: sample_count * component_count > t2p->tiff_datasize");
-+            t2p->t2p_error = T2P_ERR_ERROR;
-+            return 1;
-+        }
- 	
- 	for(i=sample_count;i>0;i--){
- 		palette_offset=buffer[i-1] * component_count;
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2638.patch b/media-libs/tiff/files/tiff-4.0.7-bug2638.patch
deleted file mode 100644
index 15541576c58..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2638.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 9f5536843f2ae641542bb81a3023dbc581fac184 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Tue, 20 Dec 2016 17:13:26 +0000
-Subject: [PATCH] * tools/tiff2pdf.c: fix wrong usage of memcpy() that can
- trigger unspecified behaviour. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2638
-
----
- ChangeLog        | 6 ++++++
- tools/tiff2pdf.c | 5 +++--
- 2 files changed, 9 insertions(+), 2 deletions(-)
-
-diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
-index afea414bebf6..78ffa77d123a 100644
---- a/tools/tiff2pdf.c
-+++ b/tools/tiff2pdf.c
-@@ -3593,7 +3593,8 @@ void t2p_tile_collapse_left(
- 	
- 	edgescanwidth = (scanwidth * edgetilewidth + (tilewidth - 1))/ tilewidth;
- 	for(i=0;i<tilelength;i++){
--		_TIFFmemcpy( 
-+                /* We use memmove() since there can be overlaps in src and dst buffers for the first items */
-+		memmove( 
- 			&(((char*)buffer)[edgescanwidth*i]), 
- 			&(((char*)buffer)[scanwidth*i]), 
- 			edgescanwidth);
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2639.patch b/media-libs/tiff/files/tiff-4.0.7-bug2639.patch
deleted file mode 100644
index b894775dc70..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2639.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From 6a61192a98665d870dcb835452cb9c5757ccd27c Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Tue, 20 Dec 2016 17:24:35 +0000
-Subject: [PATCH] * tools/tiff2pdf.c: avoid potential invalid memory read in
- t2p_writeproc. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2639
-
----
- ChangeLog        |  6 ++++++
- tools/tiff2pdf.c | 20 +++++++++++---------
- 2 files changed, 17 insertions(+), 9 deletions(-)
-
-diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
-index 78ffa77d123a..5348f1a765fe 100644
---- a/tools/tiff2pdf.c
-+++ b/tools/tiff2pdf.c
-@@ -2896,6 +2896,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_
- 			}
- 			if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0) {
- 				if (count >= 4) {
-+                                        int retTIFFReadRawTile;
-                     /* Ignore EOI marker of JpegTables */
- 					_TIFFmemcpy(buffer, jpt, count - 2);
- 					bufferoffset += count - 2;
-@@ -2903,22 +2904,23 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_
- 					table_end[0] = buffer[bufferoffset-2];
- 					table_end[1] = buffer[bufferoffset-1];
- 					xuint32 = bufferoffset;
--                    bufferoffset -= 2;
--					bufferoffset += TIFFReadRawTile(
-+                                        bufferoffset -= 2;
-+                                        retTIFFReadRawTile= TIFFReadRawTile(
- 						input, 
- 						tile, 
- 						(tdata_t) &(((unsigned char*)buffer)[bufferoffset]), 
- 						-1);
-+                                        if( retTIFFReadRawTile < 0 )
-+                                        {
-+                                            _TIFFfree(buffer);
-+                                            t2p->t2p_error = T2P_ERR_ERROR;
-+                                            return(0);
-+                                        }
-+					bufferoffset += retTIFFReadRawTile;
-                     /* Overwrite SOI marker of image scan with previously */
-                     /* saved end of JpegTables */
- 					buffer[xuint32-2]=table_end[0];
- 					buffer[xuint32-1]=table_end[1];
--				} else {
--					bufferoffset += TIFFReadRawTile(
--						input, 
--						tile, 
--						(tdata_t) &(((unsigned char*)buffer)[bufferoffset]), 
--						-1);
- 				}
- 			}
- 			t2pWriteFile(output, (tdata_t) buffer, bufferoffset);
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2640.patch b/media-libs/tiff/files/tiff-4.0.7-bug2640.patch
deleted file mode 100644
index 2569f47a54b..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2640.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 548b62fae49637b621766c721884d59a55c9a2d8 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Tue, 20 Dec 2016 17:28:17 +0000
-Subject: [PATCH] * tools/tiff2pdf.c: avoid potential heap-based overflow in
- t2p_readwrite_pdf_image_tile(). Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2640
-
----
- ChangeLog        | 6 ++++++
- tools/tiff2pdf.c | 4 ++--
- 2 files changed, 8 insertions(+), 2 deletions(-)
-
-diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
-index 5348f1a765fe..8e4e24ef9e82 100644
---- a/tools/tiff2pdf.c
-+++ b/tools/tiff2pdf.c
-@@ -2895,7 +2895,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_
- 				return(0);
- 			}
- 			if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0) {
--				if (count >= 4) {
-+				if (count > 4) {
-                                         int retTIFFReadRawTile;
-                     /* Ignore EOI marker of JpegTables */
- 					_TIFFmemcpy(buffer, jpt, count - 2);
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2642-bug2643-bug2646-bug2647.patch b/media-libs/tiff/files/tiff-4.0.7-bug2642-bug2643-bug2646-bug2647.patch
deleted file mode 100644
index 6f01774b9d5..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2642-bug2643-bug2646-bug2647.patch
+++ /dev/null
@@ -1,278 +0,0 @@
-From f049eba476a1ed60adc6534452ccf0022c2d1908 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Wed, 11 Jan 2017 16:09:02 +0000
-Subject: [PATCH] * 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. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2643
- http://bugzilla.maptools.org/show_bug.cgi?id=2642
- http://bugzilla.maptools.org/show_bug.cgi?id=2646
- http://bugzilla.maptools.org/show_bug.cgi?id=2647
-
----
- ChangeLog              | 10 ++++++
- libtiff/tif_dir.c      | 20 ++++++++---
- libtiff/tif_dirread.c  | 12 +++++--
- libtiff/tif_dirwrite.c | 92 ++++++++++++++++++++++++++++++++++++++++++++------
- 4 files changed, 116 insertions(+), 18 deletions(-)
-
-diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c
-index 2574e748b3be..36c7ae57641a 100644
---- a/libtiff/tif_dir.c
-+++ b/libtiff/tif_dir.c
-@@ -31,6 +31,7 @@
-  * (and also some miscellaneous stuff)
-  */
- #include "tiffiop.h"
-+#include <float.h>
- 
- /*
-  * These are used in the backwards compatibility code...
-@@ -154,6 +155,15 @@ bad:
- 	return (0);
- }
- 
-+static float TIFFClampDoubleToFloat( double val )
-+{
-+    if( val > FLT_MAX )
-+        return FLT_MAX;
-+    if( val < -FLT_MAX )
-+        return -FLT_MAX;
-+    return (float)val;
-+}
-+
- static int
- _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
- {
-@@ -312,13 +322,13 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
-         dblval = va_arg(ap, double);
-         if( dblval < 0 )
-             goto badvaluedouble;
--		td->td_xresolution = (float) dblval;
-+		td->td_xresolution = TIFFClampDoubleToFloat( dblval );
- 		break;
- 	case TIFFTAG_YRESOLUTION:
-         dblval = va_arg(ap, double);
-         if( dblval < 0 )
-             goto badvaluedouble;
--		td->td_yresolution = (float) dblval;
-+		td->td_yresolution = TIFFClampDoubleToFloat( dblval );
- 		break;
- 	case TIFFTAG_PLANARCONFIG:
- 		v = (uint16) va_arg(ap, uint16_vap);
-@@ -327,10 +337,10 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
- 		td->td_planarconfig = (uint16) v;
- 		break;
- 	case TIFFTAG_XPOSITION:
--		td->td_xposition = (float) va_arg(ap, double);
-+		td->td_xposition = TIFFClampDoubleToFloat( va_arg(ap, double) );
- 		break;
- 	case TIFFTAG_YPOSITION:
--		td->td_yposition = (float) va_arg(ap, double);
-+		td->td_yposition = TIFFClampDoubleToFloat( va_arg(ap, double) );
- 		break;
- 	case TIFFTAG_RESOLUTIONUNIT:
- 		v = (uint16) va_arg(ap, uint16_vap);
-diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
-index eae3430612d0..f8628fd6d5d2 100644
---- a/libtiff/tif_dirread.c
-+++ b/libtiff/tif_dirread.c
-@@ -40,6 +40,7 @@
-  */
- 
- #include "tiffiop.h"
-+#include <float.h>
- 
- #define IGNORE 0          /* tag placeholder used below */
- #define FAILED_FII    ((uint32) -1)
-@@ -2406,7 +2407,14 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt
- 				ma=(double*)origdata;
- 				mb=data;
- 				for (n=0; n<count; n++)
--					*mb++=(float)(*ma++);
-+                                {
-+                                    double val = *ma++;
-+                                    if( val > FLT_MAX )
-+                                        val = FLT_MAX;
-+                                    else if( val < -FLT_MAX )
-+                                        val = -FLT_MAX;
-+                                    *mb++=(float)val;
-+                                }
- 			}
- 			break;
- 	}
-diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
-index 055324db078f..f7339685130d 100644
---- a/libtiff/tif_dirwrite.c
-+++ b/libtiff/tif_dirwrite.c
-@@ -30,6 +30,7 @@
-  * Directory Write Support Routines.
-  */
- #include "tiffiop.h"
-+#include <float.h>
- 
- #ifdef HAVE_IEEEFP
- #define TIFFCvtNativeToIEEEFloat(tif, n, fp)
-@@ -939,6 +940,69 @@ bad:
- 	return(0);
- }
- 
-+static float TIFFClampDoubleToFloat( double val )
-+{
-+    if( val > FLT_MAX )
-+        return FLT_MAX;
-+    if( val < -FLT_MAX )
-+        return -FLT_MAX;
-+    return (float)val;
-+}
-+
-+static int8 TIFFClampDoubleToInt8( double val )
-+{
-+    if( val > 127 )
-+        return 127;
-+    if( val < -128 || val != val )
-+        return -128;
-+    return (int8)val;
-+}
-+
-+static int16 TIFFClampDoubleToInt16( double val )
-+{
-+    if( val > 32767 )
-+        return 32767;
-+    if( val < -32768 || val != val )
-+        return -32768;
-+    return (int16)val;
-+}
-+
-+static int32 TIFFClampDoubleToInt32( double val )
-+{
-+    if( val > 0x7FFFFFFF )
-+        return 0x7FFFFFFF;
-+    if( val < -0x7FFFFFFF-1 || val != val )
-+        return -0x7FFFFFFF-1;
-+    return (int32)val;
-+}
-+
-+static uint8 TIFFClampDoubleToUInt8( double val )
-+{
-+    if( val < 0 )
-+        return 0;
-+    if( val > 255 || val != val )
-+        return 255;
-+    return (uint8)val;
-+}
-+
-+static uint16 TIFFClampDoubleToUInt16( double val )
-+{
-+    if( val < 0 )
-+        return 0;
-+    if( val > 65535 || val != val )
-+        return 65535;
-+    return (uint16)val;
-+}
-+
-+static uint32 TIFFClampDoubleToUInt32( double val )
-+{
-+    if( val < 0 )
-+        return 0;
-+    if( val > 0xFFFFFFFFU || val != val )
-+        return 0xFFFFFFFFU;
-+    return (uint32)val;
-+}
-+
- static int
- TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value)
- {
-@@ -959,7 +1023,7 @@ TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di
- 			if (tif->tif_dir.td_bitspersample<=32)
- 			{
- 				for (i = 0; i < count; ++i)
--					((float*)conv)[i] = (float)value[i];
-+					((float*)conv)[i] = TIFFClampDoubleToFloat(value[i]);
- 				ok = TIFFWriteDirectoryTagFloatArray(tif,ndir,dir,tag,count,(float*)conv);
- 			}
- 			else
-@@ -971,19 +1035,19 @@ TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di
- 			if (tif->tif_dir.td_bitspersample<=8)
- 			{
- 				for (i = 0; i < count; ++i)
--					((int8*)conv)[i] = (int8)value[i];
-+					((int8*)conv)[i] = TIFFClampDoubleToInt8(value[i]);
- 				ok = TIFFWriteDirectoryTagSbyteArray(tif,ndir,dir,tag,count,(int8*)conv);
- 			}
- 			else if (tif->tif_dir.td_bitspersample<=16)
- 			{
- 				for (i = 0; i < count; ++i)
--					((int16*)conv)[i] = (int16)value[i];
-+					((int16*)conv)[i] = TIFFClampDoubleToInt16(value[i]);
- 				ok = TIFFWriteDirectoryTagSshortArray(tif,ndir,dir,tag,count,(int16*)conv);
- 			}
- 			else
- 			{
- 				for (i = 0; i < count; ++i)
--					((int32*)conv)[i] = (int32)value[i];
-+					((int32*)conv)[i] = TIFFClampDoubleToInt32(value[i]);
- 				ok = TIFFWriteDirectoryTagSlongArray(tif,ndir,dir,tag,count,(int32*)conv);
- 			}
- 			break;
-@@ -991,19 +1055,19 @@ TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di
- 			if (tif->tif_dir.td_bitspersample<=8)
- 			{
- 				for (i = 0; i < count; ++i)
--					((uint8*)conv)[i] = (uint8)value[i];
-+					((uint8*)conv)[i] = TIFFClampDoubleToUInt8(value[i]);
- 				ok = TIFFWriteDirectoryTagByteArray(tif,ndir,dir,tag,count,(uint8*)conv);
- 			}
- 			else if (tif->tif_dir.td_bitspersample<=16)
- 			{
- 				for (i = 0; i < count; ++i)
--					((uint16*)conv)[i] = (uint16)value[i];
-+					((uint16*)conv)[i] = TIFFClampDoubleToUInt16(value[i]);
- 				ok = TIFFWriteDirectoryTagShortArray(tif,ndir,dir,tag,count,(uint16*)conv);
- 			}
- 			else
- 			{
- 				for (i = 0; i < count; ++i)
--					((uint32*)conv)[i] = (uint32)value[i];
-+					((uint32*)conv)[i] = TIFFClampDoubleToUInt32(value[i]);
- 				ok = TIFFWriteDirectoryTagLongArray(tif,ndir,dir,tag,count,(uint32*)conv);
- 			}
- 			break;
-@@ -2102,12 +2166,17 @@ TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir,
-             TIFFErrorExt(tif->tif_clientdata,module,"Negative value is illegal");
-             return 0;
-         }
-+        else if( value != value )
-+        {
-+            TIFFErrorExt(tif->tif_clientdata,module,"Not-a-number value is illegal");
-+            return 0;
-+        }
- 	else if (value==0.0)
- 	{
- 		m[0]=0;
- 		m[1]=1;
- 	}
--	else if (value==(double)(uint32)value)
-+	else if (value <= 0xFFFFFFFFU && value==(double)(uint32)value)
- 	{
- 		m[0]=(uint32)value;
- 		m[1]=1;
-@@ -2148,12 +2217,13 @@ TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry*
- 	}
- 	for (na=value, nb=m, nc=0; nc<count; na++, nb+=2, nc++)
- 	{
--		if (*na<=0.0)
-+		if (*na<=0.0 || *na != *na)
- 		{
- 			nb[0]=0;
- 			nb[1]=1;
- 		}
--		else if (*na==(float)(uint32)(*na))
-+		else if (*na >= 0 && *na <= (float)0xFFFFFFFFU &&
-+                         *na==(float)(uint32)(*na))
- 		{
- 			nb[0]=(uint32)(*na);
- 			nb[1]=1;
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2644.patch b/media-libs/tiff/files/tiff-4.0.7-bug2644.patch
deleted file mode 100644
index b4ec01a3217..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2644.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-From 699097af4e22e48fc78ae7ae02807ec37f0d31fe Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-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
-
----
- ChangeLog             |  8 ++++++++
- libtiff/tif_dirread.c | 12 +++++++++---
- 2 files changed, 17 insertions(+), 3 deletions(-)
-
-diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
-index f2905286c0d0..eae3430612d0 100644
---- a/libtiff/tif_dirread.c
-+++ b/libtiff/tif_dirread.c
-@@ -2872,7 +2872,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedRational(TIFF* tif, TIFFD
- 		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];
-@@ -2900,7 +2903,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFF
- 		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];
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2648.patch b/media-libs/tiff/files/tiff-4.0.7-bug2648.patch
deleted file mode 100644
index a3e2f59dc27..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2648.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 569ffefa61f3237fa2221730621c869216c465a6 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Wed, 11 Jan 2017 16:13:50 +0000
-Subject: [PATCH] * libtiff/tif_jpeg.c: validate BitsPerSample in
- JPEGSetupEncode() to avoid undefined behaviour caused by invalid shift
- exponent. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2648
-
----
- ChangeLog          | 6 ++++++
- libtiff/tif_jpeg.c | 9 ++++++++-
- 2 files changed, 14 insertions(+), 1 deletion(-)
-
-diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c
-index 09ef4949f9ee..e45e2a4e17f8 100644
---- a/libtiff/tif_jpeg.c
-+++ b/libtiff/tif_jpeg.c
-@@ -1632,6 +1632,13 @@ JPEGSetupEncode(TIFF* tif)
-                             "Invalig horizontal/vertical sampling value");
-                     return (0);
-                 }
-+                if( td->td_bitspersample > 16 )
-+                {
-+                    TIFFErrorExt(tif->tif_clientdata, module,
-+                                 "BitsPerSample %d not allowed for JPEG",
-+                                 td->td_bitspersample);
-+                    return (0);
-+                }
- 
- 		/*
- 		 * A ReferenceBlackWhite field *must* be present since the
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2650-2.patch b/media-libs/tiff/files/tiff-4.0.7-bug2650-2.patch
deleted file mode 100644
index eba5b8f50ba..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2650-2.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From 08e5d199b0a1c80fc81a1cc718e5d9d019517e37 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Wed, 11 Jan 2017 17:48:11 +0000
-Subject: [PATCH] Initialize variable to fix MSVC warning (caused by previous
- commit)
-
----
- libtiff/tif_read.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c
-index 8c5af6a8f5f7..b2edb029a90c 100644
---- a/libtiff/tif_read.c
-+++ b/libtiff/tif_read.c
-@@ -420,7 +420,7 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size,
- 			return ((tmsize_t)(-1));
- 		}
- 	} else {
--		tmsize_t ma;
-+		tmsize_t ma = 0;
- 		tmsize_t n;
- 		if ((td->td_stripoffset[strip] > (uint64)TIFF_TMSIZE_T_MAX)||
-                     ((ma=(tmsize_t)td->td_stripoffset[strip])>tif->tif_size))
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2650.patch b/media-libs/tiff/files/tiff-4.0.7-bug2650.patch
deleted file mode 100644
index 2aac26987d5..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2650.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From 5368b55d0f88a34ede3d21782d3142b2e11e6eb9 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Wed, 11 Jan 2017 16:33:34 +0000
-Subject: [PATCH] * libtiff/tif_read.c: avoid potential undefined behaviour on
- signed integer addition in TIFFReadRawStrip1() in isMapped() case. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2650
-
----
- ChangeLog          |  6 ++++++
- libtiff/tif_read.c | 29 +++++++++++++++++++----------
- 2 files changed, 25 insertions(+), 10 deletions(-)
-
-diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c
-index 29a311db0cb7..8c5af6a8f5f7 100644
---- a/libtiff/tif_read.c
-+++ b/libtiff/tif_read.c
-@@ -420,16 +420,25 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size,
- 			return ((tmsize_t)(-1));
- 		}
- 	} else {
--		tmsize_t ma,mb;
-+		tmsize_t ma;
- 		tmsize_t n;
--		ma=(tmsize_t)td->td_stripoffset[strip];
--		mb=ma+size;
--		if ((td->td_stripoffset[strip] > (uint64)TIFF_TMSIZE_T_MAX)||(ma>tif->tif_size))
--			n=0;
--		else if ((mb<ma)||(mb<size)||(mb>tif->tif_size))
--			n=tif->tif_size-ma;
--		else
--			n=size;
-+		if ((td->td_stripoffset[strip] > (uint64)TIFF_TMSIZE_T_MAX)||
-+                    ((ma=(tmsize_t)td->td_stripoffset[strip])>tif->tif_size))
-+                {
-+                    n=0;
-+                }
-+                else if( ma > TIFF_TMSIZE_T_MAX - size )
-+                {
-+                    n=0;
-+                }
-+                else
-+                {
-+                    tmsize_t mb=ma+size;
-+                    if (mb>tif->tif_size)
-+                            n=tif->tif_size-ma;
-+                    else
-+                            n=size;
-+                }
- 		if (n!=size) {
- #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- 			TIFFErrorExt(tif->tif_clientdata, module,
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2651.patch b/media-libs/tiff/files/tiff-4.0.7-bug2651.patch
deleted file mode 100644
index 1b800189c59..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2651.patch
+++ /dev/null
@@ -1,86 +0,0 @@
-From 669faf71833c4c2e72774b2e732ca4d28b149c83 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Wed, 11 Jan 2017 19:02:49 +0000
-Subject: [PATCH] * libtiff/tiffiop.h, tif_unix.c, tif_win32.c, tif_vms.c: add
- _TIFFcalloc()
-
-* libtiff/tif_read.c: TIFFReadBufferSetup(): use _TIFFcalloc() to zero
-initialize tif_rawdata.
-Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2651
----
- ChangeLog           |  8 ++++++++
- libtiff/tif_read.c  |  6 ++++--
- libtiff/tif_unix.c  | 10 +++++++++-
- libtiff/tif_vms.c   | 10 +++++++++-
- libtiff/tif_win32.c | 10 +++++++++-
- libtiff/tiffio.h    |  3 ++-
- 6 files changed, 41 insertions(+), 6 deletions(-)
-
-diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c
-index b2edb029a90c..6a8c7daf3dfa 100644
---- a/libtiff/tif_read.c
-+++ b/libtiff/tif_read.c
-@@ -985,7 +985,9 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size)
- 				 "Invalid buffer size");
- 		    return (0);
- 		}
--		tif->tif_rawdata = (uint8*) _TIFFmalloc(tif->tif_rawdatasize);
-+		/* Initialize to zero to avoid uninitialized buffers in case of */
-+                /* short reads (http://bugzilla.maptools.org/show_bug.cgi?id=2651) */
-+		tif->tif_rawdata = (uint8*) _TIFFcalloc(1, tif->tif_rawdatasize);
- 		tif->tif_flags |= TIFF_MYBUFFER;
- 	}
- 	if (tif->tif_rawdata == NULL) {
-diff --git a/libtiff/tif_unix.c b/libtiff/tif_unix.c
-index 81e9d6653c2a..80c437cfa37a 100644
---- a/libtiff/tif_unix.c
-+++ b/libtiff/tif_unix.c
-@@ -316,6 +316,14 @@ _TIFFmalloc(tmsize_t s)
- 	return (malloc((size_t) s));
- }
- 
-+void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz)
-+{
-+    if( nmemb == 0 || siz == 0 )
-+        return ((void *) NULL);
-+
-+    return calloc((size_t) nmemb, (size_t)siz);
-+}
-+
- void
- _TIFFfree(void* p)
- {
-diff --git a/libtiff/tif_win32.c b/libtiff/tif_win32.c
-index 24b824f1bd56..090baed87135 100644
---- a/libtiff/tif_win32.c
-+++ b/libtiff/tif_win32.c
-@@ -360,6 +360,14 @@ _TIFFmalloc(tmsize_t s)
- 	return (malloc((size_t) s));
- }
- 
-+void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz)
-+{
-+    if( nmemb == 0 || siz == 0 )
-+        return ((void *) NULL);
-+
-+    return calloc((size_t) nmemb, (size_t)siz);
-+}
-+
- void
- _TIFFfree(void* p)
- {
-diff --git a/libtiff/tiffio.h b/libtiff/tiffio.h
-index 6e508181dbce..ef61b5c06a03 100644
---- a/libtiff/tiffio.h
-+++ b/libtiff/tiffio.h
-@@ -293,6 +293,7 @@ extern TIFFCodec* TIFFGetConfiguredCODECs(void);
-  */
- 
- extern void* _TIFFmalloc(tmsize_t s);
-+extern void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz);
- extern void* _TIFFrealloc(void* p, tmsize_t s);
- extern void _TIFFmemset(void* p, int v, tmsize_t c);
- extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c);
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2653.patch b/media-libs/tiff/files/tiff-4.0.7-bug2653.patch
deleted file mode 100644
index b65a94daeac..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2653.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 5083c41f3a6824f392adf3a6dce1548afded4211 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Wed, 11 Jan 2017 12:15:01 +0000
-Subject: [PATCH] * libtiff/tif_jpeg.c: avoid integer division by zero in
- JPEGSetupEncode() when horizontal or vertical sampling is set to 0. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2653
-
----
- ChangeLog          | 6 ++++++
- libtiff/tif_jpeg.c | 9 ++++++++-
- 2 files changed, 14 insertions(+), 1 deletion(-)
-
-diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c
-index dc4364c821a4..09ef4949f9ee 100644
---- a/libtiff/tif_jpeg.c
-+++ b/libtiff/tif_jpeg.c
-@@ -1626,6 +1626,13 @@ JPEGSetupEncode(TIFF* tif)
- 	case PHOTOMETRIC_YCBCR:
- 		sp->h_sampling = td->td_ycbcrsubsampling[0];
- 		sp->v_sampling = td->td_ycbcrsubsampling[1];
-+                if( sp->h_sampling == 0 || sp->v_sampling == 0 )
-+                {
-+                    TIFFErrorExt(tif->tif_clientdata, module,
-+                            "Invalig horizontal/vertical sampling value");
-+                    return (0);
-+                }
-+
- 		/*
- 		 * A ReferenceBlackWhite field *must* be present since the
- 		 * default value is inappropriate for YCbCr.  Fill in the
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2658.patch b/media-libs/tiff/files/tiff-4.0.7-bug2658.patch
deleted file mode 100644
index 9f2bb6a50ee..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2658.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 928f0b0b2881ac32b32d9e165e88e3c9aed0fb9c Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Wed, 11 Jan 2017 16:38:26 +0000
-Subject: [PATCH] =?UTF-8?q?*=20libtiff/tif=5Fgetimage.c:=20add=20explicit?=
- =?UTF-8?q?=20uint32=20cast=20in=20putagreytile=20to=20avoid=20UndefinedBe?=
- =?UTF-8?q?haviorSanitizer=20warning.=20Patch=20by=20Nicol=C3=A1s=20Pe?=
- =?UTF-8?q?=C3=B1a.=20Fixes=20http://bugzilla.maptools.org/show=5Fbug.cgi?=
- =?UTF-8?q?=3Fid=3D2658?=
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
----
- ChangeLog              | 7 +++++++
- libtiff/tif_getimage.c | 4 ++--
- 2 files changed, 9 insertions(+), 2 deletions(-)
-
-diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c
-index 2ea838556732..52a2402f7171 100644
---- a/libtiff/tif_getimage.c
-+++ b/libtiff/tif_getimage.c
-@@ -1302,7 +1302,7 @@ DECLAREContigPutFunc(putagreytile)
-     while (h-- > 0) {
- 	for (x = w; x-- > 0;)
-         {
--            *cp++ = BWmap[*pp][0] & (*(pp+1) << 24 | ~A1);
-+            *cp++ = BWmap[*pp][0] & ((uint32)*(pp+1) << 24 | ~A1);
-             pp += samplesperpixel;
-         }
- 	cp += toskew;
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2659-2.patch b/media-libs/tiff/files/tiff-4.0.7-bug2659-2.patch
deleted file mode 100644
index 539536fe4ff..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2659-2.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From 41236c5f744eaa691e23e55f5a5dd556a65e211e Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Thu, 12 Jan 2017 19:23:20 +0000
-Subject: [PATCH] * libtiff/tif_ojpeg.c: fix leak in
- OJPEGReadHeaderInfoSecTablesQTable, OJPEGReadHeaderInfoSecTablesDcTable and
- OJPEGReadHeaderInfoSecTablesAcTable
-
----
- ChangeLog           | 3 ++-
- libtiff/tif_ojpeg.c | 8 +++++++-
- 2 files changed, 9 insertions(+), 2 deletions(-)
-
-diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c
-index ac70d1b14c4f..bd4cff5d8921 100644
---- a/libtiff/tif_ojpeg.c
-+++ b/libtiff/tif_ojpeg.c
-@@ -1790,7 +1790,10 @@ OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif)
- 			TIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET); 
- 			p=(uint32)TIFFReadFile(tif,&ob[sizeof(uint32)+5],64);
- 			if (p!=64)
-+                        {
-+                                _TIFFfree(ob);
- 				return(0);
-+                        }
- 			sp->qtable[m]=ob;
- 			sp->sof_tq[m]=m;
- 		}
-@@ -1854,7 +1857,10 @@ OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif)
- 				rb[sizeof(uint32)+5+n]=o[n];
- 			p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q);
- 			if (p!=q)
-+                        {
-+                                _TIFFfree(rb);
- 				return(0);
-+                        }
- 			sp->dctable[m]=rb;
- 			sp->sos_tda[m]=(m<<4);
- 		}
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2659.patch b/media-libs/tiff/files/tiff-4.0.7-bug2659.patch
deleted file mode 100644
index 8afab46b888..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2659.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 7c501dbfb5315f31798f9123026210260cbe7432 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Thu, 12 Jan 2017 17:43:25 +0000
-Subject: [PATCH] =?UTF-8?q?*=20libtiff/tif=5Fojpeg.c:=20fix=20leak=20in=20?=
- =?UTF-8?q?OJPEGReadHeaderInfoSecTablesAcTable=20when=20read=20fails.=20Pa?=
- =?UTF-8?q?tch=20by=20Nicol=C3=A1s=20Pe=C3=B1a.=20Fixes=20http://bugzilla.?=
- =?UTF-8?q?maptools.org/show=5Fbug.cgi=3Fid=3D2659?=
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
----
- ChangeLog           | 7 +++++++
- libtiff/tif_ojpeg.c | 5 ++++-
- 2 files changed, 11 insertions(+), 1 deletion(-)
-
-diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c
-index 93839d8f3e11..ac70d1b14c4f 100644
---- a/libtiff/tif_ojpeg.c
-+++ b/libtiff/tif_ojpeg.c
-@@ -1918,7 +1918,10 @@ OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif)
- 				rb[sizeof(uint32)+5+n]=o[n];
- 			p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q);
- 			if (p!=q)
-+                        {
-+                                _TIFFfree(rb);
- 				return(0);
-+                        }
- 			sp->actable[m]=rb;
- 			sp->sos_tda[m]=(sp->sos_tda[m]|m);
- 		}
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-bug2665.patch b/media-libs/tiff/files/tiff-4.0.7-bug2665.patch
deleted file mode 100644
index 020adca8e7a..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-bug2665.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From e345ce2ad81c85eb8e469b7b959067b2681957ca Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Sat, 18 Feb 2017 20:30:26 +0000
-Subject: [PATCH] =?UTF-8?q?*=20libtiff/tif=5Fpixarlog.c:=20fix=20memory=20?=
- =?UTF-8?q?leak=20in=20error=20code=20path=20of=20PixarLogSetupDecode().?=
- =?UTF-8?q?=20Patch=20by=20Nicol=C3=A1s=20Pe=C3=B1a.=20Fixes=20http://bugz?=
- =?UTF-8?q?illa.maptools.org/show=5Fbug.cgi=3Fid=3D2665?=
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
----
- ChangeLog              | 6 ++++++
- libtiff/tif_pixarlog.c | 8 +++++++-
- 2 files changed, 13 insertions(+), 1 deletion(-)
-
-diff --git a/libtiff/tif_pixarlog.c b/libtiff/tif_pixarlog.c
-index 9836dce63450..972ee75e0324 100644
---- a/libtiff/tif_pixarlog.c
-+++ b/libtiff/tif_pixarlog.c
-@@ -699,6 +699,9 @@ PixarLogSetupDecode(TIFF* tif)
- 	if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
- 		sp->user_datafmt = PixarLogGuessDataFmt(td);
- 	if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) {
-+                _TIFFfree(sp->tbuf);
-+                sp->tbuf = NULL;
-+                sp->tbuf_size = 0;
- 		TIFFErrorExt(tif->tif_clientdata, module,
- 			"PixarLog compression can't handle bits depth/data format combination (depth: %d)", 
- 			td->td_bitspersample);
-@@ -706,6 +709,9 @@ PixarLogSetupDecode(TIFF* tif)
- 	}
- 
- 	if (inflateInit(&sp->stream) != Z_OK) {
-+                _TIFFfree(sp->tbuf);
-+                sp->tbuf = NULL;
-+                sp->tbuf_size = 0;
- 		TIFFErrorExt(tif->tif_clientdata, module, "%s", sp->stream.msg ? sp->stream.msg : "(null)");
- 		return (0);
- 	} else {
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-fax2tiff.patch b/media-libs/tiff/files/tiff-4.0.7-fax2tiff.patch
deleted file mode 100644
index f3476e98d6f..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-fax2tiff.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-https://bugs.gentoo.org/598938
-
-From 82c53c6f19d8d7854b9b88aa16802f31b1cc258c Mon Sep 17 00:00:00 2001
-From: Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-Date: Sun, 20 Nov 2016 18:04:52 +0000
-Subject: [PATCH] =?UTF-8?q?*=20tools/fax2tiff.c=20(main):=20Applied=20patc?=
- =?UTF-8?q?h=20by=20J=C3=B6rg=20Ahrens=20to=20fix=20passing=20client=20dat?=
- =?UTF-8?q?a=20for=20Win32=20builds=20using=20tif=5Fwin32.c=20(USE=5FWIN32?=
- =?UTF-8?q?=5FFILEIO=20defined)=20for=20file=20I/O.=20=20Patch=20was=20pro?=
- =?UTF-8?q?vided=20via=20email=20on=20November=2020,=202016.?=
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
----
- ChangeLog        | 7 +++++++
- tools/fax2tiff.c | 5 +++--
- 2 files changed, 10 insertions(+), 2 deletions(-)
-
-diff --git a/tools/fax2tiff.c b/tools/fax2tiff.c
-index e00de5277bc2..01f85540ac9c 100644
---- a/tools/fax2tiff.c
-+++ b/tools/fax2tiff.c
-@@ -283,10 +283,11 @@ main(int argc, char* argv[])
- 		}
- #if defined(_WIN32) && defined(USE_WIN32_FILEIO)
-                 client_data.fh = _get_osfhandle(fileno(in));
-+                TIFFSetClientdata(faxTIFF, (thandle_t) client_data.fh);
- #else
-                 client_data.fd = fileno(in);
-+                TIFFSetClientdata(faxTIFF, (thandle_t) client_data.fd);
- #endif
--                TIFFSetClientdata(faxTIFF, (thandle_t) &client_data);
- 		TIFFSetFileName(faxTIFF, (const char*)argv[optind]);
- 		TIFFSetField(out, TIFFTAG_IMAGEWIDTH, xsize);
- 		TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1);
--- 
-2.12.0
-

diff --git a/media-libs/tiff/files/tiff-4.0.7-hylafax-hack.patch b/media-libs/tiff/files/tiff-4.0.7-hylafax-hack.patch
deleted file mode 100644
index 69158200ac7..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-hylafax-hack.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-https://bugs.gentoo.org/612172
-
-From 96bb01f5d834e0b01c0231768c43b8d309aede34 Mon Sep 17 00:00:00 2001
-From: Even Rouault <even.rouault@spatialys.com>
-Date: Tue, 13 Dec 2016 18:15:48 +0000
-Subject: [PATCH] * libtiff/tif_fax3.h: revert change done on 2016-01-09 that
- made Param member of TIFFFaxTabEnt structure a uint16 to reduce size of the
- binary. It happens that the Hylafax software uses the tables that follow this
- typedef (TIFFFaxMainTable, TIFFFaxWhiteTable, TIFFFaxBlackTable), also they
- are not in a public libtiff header. Raised by Lee Howard. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2636
-
----
- ChangeLog          | 10 ++++++++++
- libtiff/tif_fax3.h |  6 ++++--
- 2 files changed, 14 insertions(+), 2 deletions(-)
-
-diff --git a/libtiff/tif_fax3.h b/libtiff/tif_fax3.h
-index e0b2ca6bfc9d..45ce43f1cf2e 100644
---- a/libtiff/tif_fax3.h
-+++ b/libtiff/tif_fax3.h
-@@ -81,10 +81,12 @@ extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32);
- #define S_MakeUp   11
- #define S_EOL      12
- 
-+/* WARNING: do not change the layout of this structure as the Halyfax software */
-+/* really depends on it. See http://bugzilla.maptools.org/show_bug.cgi?id=2636 */
- typedef struct {                /* state table entry */
- 	unsigned char State;    /* see above */
- 	unsigned char Width;    /* width of code in bits */
--	uint16 Param;           /* unsigned 16-bit run length in bits */
-+	uint32 Param;           /* unsigned 32-bit run length in bits (holds on 16 bit actually, but cannot be changed. See above warning) */
- } TIFFFaxTabEnt;
- 
- extern const TIFFFaxTabEnt TIFFFaxMainTable[];
--- 
-2.12.0
-

diff --git a/media-libs/tiff/tiff-4.0.7-r3.ebuild b/media-libs/tiff/tiff-4.0.7-r3.ebuild
deleted file mode 100644
index b77d5196171..00000000000
--- a/media-libs/tiff/tiff-4.0.7-r3.ebuild
+++ /dev/null
@@ -1,121 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-inherit autotools eutils libtool multilib-minimal
-
-DESCRIPTION="Tag Image File Format (TIFF) library"
-HOMEPAGE="http://libtiff.maptools.org"
-SRC_URI="http://download.osgeo.org/libtiff/${P}.tar.gz
-	ftp://ftp.remotesensing.org/pub/libtiff/${P}.tar.gz"
-
-LICENSE="libtiff"
-SLOT="0"
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x64-cygwin ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~x64-solaris ~x86-solaris"
-IUSE="+cxx jbig jpeg lzma static-libs test zlib"
-
-RDEPEND="jpeg? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
-	jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
-	lzma? ( >=app-arch/xz-utils-5.0.5-r1:=[${MULTILIB_USEDEP}] )
-	zlib? ( >=sys-libs/zlib-1.2.8-r1:=[${MULTILIB_USEDEP}] )
-	abi_x86_32? (
-		!<=app-emulation/emul-linux-x86-baselibs-20130224-r9
-		!app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
-	)"
-DEPEND="${RDEPEND}"
-
-REQUIRED_USE="test? ( jpeg )" #483132
-
-PATCHES=(
-	"${FILESDIR}"/${P}-fax2tiff.patch #598938
-	"${FILESDIR}"/${P}-CVE-2016-10266.patch
-	"${FILESDIR}"/${P}-bug2598.patch
-	"${FILESDIR}"/${P}-bug2604.patch
-	"${FILESDIR}"/${P}-bug2608.patch
-	"${FILESDIR}"/${P}-CVE-2016-10267.patch
-	"${FILESDIR}"/${P}-bug2620.patch
-	"${FILESDIR}"/${P}-bug2621.patch
-	"${FILESDIR}"/${P}-bug2619.patch
-	"${FILESDIR}"/${P}-bug2594.patch
-	"${FILESDIR}"/${P}-bug2597.patch
-	"${FILESDIR}"/${P}-bug2599.patch
-	"${FILESDIR}"/${P}-bug2607.patch
-	"${FILESDIR}"/${P}-bug2610.patch
-	"${FILESDIR}"/${P}-bug2605.patch
-	"${FILESDIR}"/${P}-hylafax-hack.patch #612172
-	"${FILESDIR}"/${P}-bug2633-bug2634.patch
-	"${FILESDIR}"/${P}-bug2635.patch
-	"${FILESDIR}"/${P}-bug2627.patch
-	"${FILESDIR}"/${P}-bug2638.patch
-	"${FILESDIR}"/${P}-bug2639.patch
-	"${FILESDIR}"/${P}-bug2640.patch
-	"${FILESDIR}"/${P}-bug2653.patch
-	"${FILESDIR}"/${P}-bug2535.patch
-	"${FILESDIR}"/${P}-bug2644.patch
-	"${FILESDIR}"/${P}-bug2642-bug2643-bug2646-bug2647.patch
-	"${FILESDIR}"/${P}-bug2648.patch
-	"${FILESDIR}"/${P}-bug2650.patch
-	"${FILESDIR}"/${P}-bug2658.patch
-	"${FILESDIR}"/${P}-bug2650-2.patch
-	"${FILESDIR}"/${P}-bug2651.patch
-	"${FILESDIR}"/${P}-CVE-2017-5225.patch #610330
-	"${FILESDIR}"/${P}-bug2130.patch
-	"${FILESDIR}"/${P}-bug2659.patch
-	"${FILESDIR}"/${P}-bug2659-2.patch
-	"${FILESDIR}"/${P}-bug2631.patch
-	"${FILESDIR}"/${P}-bug2665.patch
-	"${FILESDIR}"/${PN}-4.0.7-pdfium-0005-Leak-TIFFFetchStripThing.patch
-	"${FILESDIR}"/${PN}-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
-	"${FILESDIR}"/${PN}-4.0.7-pdfium-0007-uninitialized-value.patch
-	"${FILESDIR}"/${PN}-4.0.7-pdfium-0008-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
-	"${FILESDIR}"/${PN}-4.0.7-pdfium-0013-validate-refblackwhite.patch
-	"${FILESDIR}"/${PN}-4.0.7-pdfium-0017-safe_skews_in_gtTileContig.patch
-	"${FILESDIR}"/${PN}-4.0.7-pdfium-0018-fix-leak-in-PredictorSetupDecode.patch
-	"${FILESDIR}"/${PN}-4.0.7-pdfium-0021-oom-TIFFFillStrip.patch
-)
-
-MULTILIB_WRAPPED_HEADERS=(
-	/usr/include/tiffconf.h
-)
-
-src_prepare() {
-	default
-
-	# tiffcp-thumbnail.sh fails as thumbnail binary doesn't get built anymore since tiff-4.0.7
-	sed '/tiffcp-thumbnail\.sh/d' -i test/Makefile.am || die
-
-	eautoreconf
-}
-
-multilib_src_configure() {
-	ECONF_SOURCE="${S}" econf \
-		$(use_enable static-libs static) \
-		$(use_enable zlib) \
-		$(use_enable jpeg) \
-		$(use_enable jbig) \
-		$(use_enable lzma) \
-		$(use_enable cxx) \
-		--without-x
-
-	# remove useless subdirs
-	if ! multilib_is_native_abi ; then
-		sed -i \
-			-e 's/ tools//' \
-			-e 's/ contrib//' \
-			-e 's/ man//' \
-			-e 's/ html//' \
-			Makefile || die
-	fi
-}
-
-multilib_src_test() {
-	if ! multilib_is_native_abi ; then
-		emake -C tools
-	fi
-	emake check
-}
-
-multilib_src_install_all() {
-	prune_libtool_files --all
-	rm -f "${ED}"/usr/share/doc/${PF}/{COPYRIGHT,README*,RELEASE-DATE,TODO,VERSION}
-}

diff --git a/media-libs/tiff/tiff-4.0.7.ebuild b/media-libs/tiff/tiff-4.0.7.ebuild
deleted file mode 100644
index 59be2b40a56..00000000000
--- a/media-libs/tiff/tiff-4.0.7.ebuild
+++ /dev/null
@@ -1,73 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=6
-inherit autotools eutils libtool multilib-minimal
-
-DESCRIPTION="Tag Image File Format (TIFF) library"
-HOMEPAGE="http://libtiff.maptools.org"
-SRC_URI="http://download.osgeo.org/libtiff/${P}.tar.gz
-	ftp://ftp.remotesensing.org/pub/libtiff/${P}.tar.gz"
-
-LICENSE="libtiff"
-SLOT="0"
-KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~x64-cygwin ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~x64-solaris ~x86-solaris"
-IUSE="+cxx jbig jpeg lzma static-libs test zlib"
-
-RDEPEND="jpeg? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
-	jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
-	lzma? ( >=app-arch/xz-utils-5.0.5-r1:=[${MULTILIB_USEDEP}] )
-	zlib? ( >=sys-libs/zlib-1.2.8-r1:=[${MULTILIB_USEDEP}] )
-	abi_x86_32? (
-		!<=app-emulation/emul-linux-x86-baselibs-20130224-r9
-		!app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
-	)"
-DEPEND="${RDEPEND}"
-
-REQUIRED_USE="test? ( jpeg )" #483132
-
-MULTILIB_WRAPPED_HEADERS=(
-	/usr/include/tiffconf.h
-)
-
-src_prepare() {
-	default
-
-	# tiffcp-thumbnail.sh fails as thumbnail binary doesn't get built anymore since tiff-4.0.7
-	sed '/tiffcp-thumbnail\.sh/d' -i test/Makefile.am || die
-
-	eautoreconf
-}
-
-multilib_src_configure() {
-	ECONF_SOURCE="${S}" econf \
-		$(use_enable static-libs static) \
-		$(use_enable zlib) \
-		$(use_enable jpeg) \
-		$(use_enable jbig) \
-		$(use_enable lzma) \
-		$(use_enable cxx) \
-		--without-x
-
-	# remove useless subdirs
-	if ! multilib_is_native_abi ; then
-		sed -i \
-			-e 's/ tools//' \
-			-e 's/ contrib//' \
-			-e 's/ man//' \
-			-e 's/ html//' \
-			Makefile || die
-	fi
-}
-
-multilib_src_test() {
-	if ! multilib_is_native_abi ; then
-		emake -C tools
-	fi
-	emake check
-}
-
-multilib_src_install_all() {
-	prune_libtool_files --all
-	rm -f "${ED}"/usr/share/doc/${PF}/{COPYRIGHT,README*,RELEASE-DATE,TODO,VERSION}
-}


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/
@ 2018-02-20 14:29 Lars Wendler
  0 siblings, 0 replies; 13+ messages in thread
From: Lars Wendler @ 2018-02-20 14:29 UTC (permalink / raw
  To: gentoo-commits

commit:     b5f874c2b8cbbdb0eb013c1543ef3aaddbe67903
Author:     Michael Vetter <jubalh <AT> iodoru <DOT> org>
AuthorDate: Tue Feb 20 14:18:53 2018 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Tue Feb 20 14:29:48 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b5f874c2

media-libs/tiff: Fix CVE-2018-5784

Patch is upstream commit:
https://gitlab.com/libtiff/libtiff/commit/473851d211cf8805a161820337ca74cc9615d6ef

Bug: https://bugs.gentoo.org/645730

Package-Manager: Portage-2.3.19, Repoman-2.3.6
Closes: https://github.com/gentoo/gentoo/pull/7237

 .../tiff/files/tiff-4.0.9-CVE-2018-5784.patch      | 128 +++++++++++++++++++++
 media-libs/tiff/tiff-4.0.9-r3.ebuild               |  84 ++++++++++++++
 2 files changed, 212 insertions(+)

diff --git a/media-libs/tiff/files/tiff-4.0.9-CVE-2018-5784.patch b/media-libs/tiff/files/tiff-4.0.9-CVE-2018-5784.patch
new file mode 100644
index 00000000000..56d0f4b0687
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.9-CVE-2018-5784.patch
@@ -0,0 +1,128 @@
+From 473851d211cf8805a161820337ca74cc9615d6ef Mon Sep 17 00:00:00 2001
+From: Nathan Baker <nathanb@lenovo-chrome.com>
+Date: Tue, 6 Feb 2018 10:13:57 -0500
+Subject: [PATCH] Fix for bug 2772
+
+It is possible to craft a TIFF document where the IFD list is circular,
+leading to an infinite loop while traversing the chain. The libtiff
+directory reader has a failsafe that will break out of this loop after
+reading 65535 directory entries, but it will continue processing,
+consuming time and resources to process what is essentially a bogus TIFF
+document.
+
+This change fixes the above behavior by breaking out of processing when
+a TIFF document has >= 65535 directories and terminating with an error.
+---
+ contrib/addtiffo/tif_overview.c | 14 +++++++++++++-
+ tools/tiff2pdf.c                | 10 ++++++++++
+ tools/tiffcrop.c                | 13 +++++++++++--
+ 3 files changed, 34 insertions(+), 3 deletions(-)
+
+diff --git a/contrib/addtiffo/tif_overview.c b/contrib/addtiffo/tif_overview.c
+index c61ffbb..03b3573 100644
+--- a/contrib/addtiffo/tif_overview.c
++++ b/contrib/addtiffo/tif_overview.c
+@@ -65,6 +65,8 @@
+ #  define MAX(a,b)      ((a>b) ? a : b)
+ #endif
+ 
++#define TIFF_DIR_MAX  65534
++
+ void TIFFBuildOverviews( TIFF *, int, int *, int, const char *,
+                          int (*)(double,void*), void * );
+ 
+@@ -91,6 +93,7 @@ uint32 TIFF_WriteOverview( TIFF *hTIFF, uint32 nXSize, uint32 nYSize,
+ {
+     toff_t	nBaseDirOffset;
+     toff_t	nOffset;
++    tdir_t	iNumDir;
+ 
+     (void) bUseSubIFDs;
+ 
+@@ -147,7 +150,16 @@ uint32 TIFF_WriteOverview( TIFF *hTIFF, uint32 nXSize, uint32 nYSize,
+         return 0;
+ 
+     TIFFWriteDirectory( hTIFF );
+-    TIFFSetDirectory( hTIFF, (tdir_t) (TIFFNumberOfDirectories(hTIFF)-1) );
++    iNumDir = TIFFNumberOfDirectories(hTIFF);
++    if( iNumDir > TIFF_DIR_MAX )
++    {
++        TIFFErrorExt( TIFFClientdata(hTIFF),
++                      "TIFF_WriteOverview",
++                      "File `%s' has too many directories.\n",
++                      TIFFFileName(hTIFF) );
++        exit(-1);
++    }
++    TIFFSetDirectory( hTIFF, (tdir_t) (iNumDir - 1) );
+ 
+     nOffset = TIFFCurrentDirOffset( hTIFF );
+ 
+diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
+index 984ef65..832a247 100644
+--- a/tools/tiff2pdf.c
++++ b/tools/tiff2pdf.c
+@@ -68,6 +68,8 @@ extern int getopt(int, char**, char*);
+ 
+ #define PS_UNIT_SIZE	72.0F
+ 
++#define TIFF_DIR_MAX    65534
++
+ /* This type is of PDF color spaces. */
+ typedef enum {
+ 	T2P_CS_BILEVEL = 0x01,	/* Bilevel, black and white */
+@@ -1051,6 +1053,14 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){
+ 	uint16* tiff_transferfunction[3];
+ 
+ 	directorycount=TIFFNumberOfDirectories(input);
++	if(directorycount > TIFF_DIR_MAX) {
++		TIFFError(
++			TIFF2PDF_MODULE,
++			"TIFF contains too many directories, %s",
++			TIFFFileName(input));
++		t2p->t2p_error = T2P_ERR_ERROR;
++		return;
++	}
+ 	t2p->tiff_pages = (T2P_PAGE*) _TIFFmalloc(TIFFSafeMultiply(tmsize_t,directorycount,sizeof(T2P_PAGE)));
+ 	if(t2p->tiff_pages==NULL){
+ 		TIFFError(
+diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
+index 91a38f6..e466dae 100644
+--- a/tools/tiffcrop.c
++++ b/tools/tiffcrop.c
+@@ -215,6 +215,8 @@ extern int getopt(int argc, char * const argv[], const char *optstring);
+ #define DUMP_TEXT   1
+ #define DUMP_RAW    2
+ 
++#define TIFF_DIR_MAX  65534
++
+ /* Offsets into buffer for margins and fixed width and length segments */
+ struct offset {
+   uint32  tmargin;
+@@ -2232,7 +2234,7 @@ main(int argc, char* argv[])
+     pageNum = -1;
+   else
+     total_images = 0;
+-  /* read multiple input files and write to output file(s) */
++  /* Read multiple input files and write to output file(s) */
+   while (optind < argc - 1)
+     {
+     in = TIFFOpen (argv[optind], "r");
+@@ -2240,7 +2242,14 @@ main(int argc, char* argv[])
+       return (-3);
+ 
+     /* If only one input file is specified, we can use directory count */
+-    total_images = TIFFNumberOfDirectories(in); 
++    total_images = TIFFNumberOfDirectories(in);
++    if (total_images > TIFF_DIR_MAX)
++      {
++      TIFFError (TIFFFileName(in), "File contains too many directories");
++      if (out != NULL)
++        (void) TIFFClose(out);
++      return (1);
++      }
+     if (image_count == 0)
+       {
+       dirnum = 0;
+--
+libgit2 0.26.0
+

diff --git a/media-libs/tiff/tiff-4.0.9-r3.ebuild b/media-libs/tiff/tiff-4.0.9-r3.ebuild
new file mode 100644
index 00000000000..b8364e2b3cf
--- /dev/null
+++ b/media-libs/tiff/tiff-4.0.9-r3.ebuild
@@ -0,0 +1,84 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit autotools libtool ltprune multilib-minimal
+
+DESCRIPTION="Tag Image File Format (TIFF) library"
+HOMEPAGE="http://libtiff.maptools.org"
+SRC_URI="http://download.osgeo.org/libtiff/${P}.tar.gz
+	ftp://ftp.remotesensing.org/pub/libtiff/${P}.tar.gz"
+
+LICENSE="libtiff"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~x64-solaris ~x86-solaris"
+IUSE="+cxx jbig jpeg lzma static-libs test zlib"
+
+RDEPEND="jpeg? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
+	jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
+	lzma? ( >=app-arch/xz-utils-5.0.5-r1:=[${MULTILIB_USEDEP}] )
+	zlib? ( >=sys-libs/zlib-1.2.8-r1:=[${MULTILIB_USEDEP}] )
+	abi_x86_32? (
+		!<=app-emulation/emul-linux-x86-baselibs-20130224-r9
+		!app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
+	)"
+DEPEND="${RDEPEND}"
+
+REQUIRED_USE="test? ( jpeg )" #483132
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0008-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
+	"${FILESDIR}"/${P}-CVE-2017-9935.patch #624696
+	"${FILESDIR}"/${P}-CVE-2017-9935-fix-incorrect-type.patch #624696
+	"${FILESDIR}"/${P}-CVE-2018-5784.patch #645730
+)
+
+MULTILIB_WRAPPED_HEADERS=(
+	/usr/include/tiffconf.h
+)
+
+src_prepare() {
+	default
+
+	# tiffcp-thumbnail.sh fails as thumbnail binary doesn't get built anymore since tiff-4.0.7
+	sed '/tiffcp-thumbnail\.sh/d' -i test/Makefile.am || die
+
+	eautoreconf
+}
+
+multilib_src_configure() {
+	local myeconfargs=(
+		--without-x
+		$(use_enable cxx)
+		$(use_enable jbig)
+		$(use_enable jpeg)
+		$(use_enable lzma)
+		$(use_enable static-libs static)
+		$(use_enable zlib)
+	)
+	ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+
+	# remove useless subdirs
+	if ! multilib_is_native_abi ; then
+		sed -i \
+			-e 's/ tools//' \
+			-e 's/ contrib//' \
+			-e 's/ man//' \
+			-e 's/ html//' \
+			Makefile || die
+	fi
+}
+
+multilib_src_test() {
+	if ! multilib_is_native_abi ; then
+		emake -C tools
+	fi
+	emake check
+}
+
+multilib_src_install_all() {
+	prune_libtool_files --all
+	rm -f "${ED%/}"/usr/share/doc/${PF}/{COPYRIGHT,README*,RELEASE-DATE,TODO,VERSION}
+}


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/
@ 2018-05-29  1:04 Mike Frysinger
  0 siblings, 0 replies; 13+ messages in thread
From: Mike Frysinger @ 2018-05-29  1:04 UTC (permalink / raw
  To: gentoo-commits

commit:     afb651b9908c9fd2d24a8e347e152bc195b486bc
Author:     Mike Frysinger <vapier <AT> chromium <DOT> org>
AuthorDate: Tue May 29 01:02:58 2018 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue May 29 01:03:54 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=afb651b9

media-libs/tiff: add upstream fix for CVE-2017-18013 #645982

Bug: https://bugs.gentoo.org/645982

 .../tiff/files/tiff-4.0.9-CVE-2017-18013.patch     | 39 +++++++++++
 media-libs/tiff/tiff-4.0.9-r4.ebuild               | 81 ++++++++++++++++++++++
 2 files changed, 120 insertions(+)

diff --git a/media-libs/tiff/files/tiff-4.0.9-CVE-2017-18013.patch b/media-libs/tiff/files/tiff-4.0.9-CVE-2017-18013.patch
new file mode 100644
index 00000000000..2db890aef90
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.9-CVE-2017-18013.patch
@@ -0,0 +1,39 @@
+https://bugs.gentoo.org/645982
+https://gitlab.com/libtiff/libtiff/commit/c6f41df7b581402dfba3c19a1e3df4454c551a01
+
+From c6f41df7b581402dfba3c19a1e3df4454c551a01 Mon Sep 17 00:00:00 2001
+From: Even Rouault <even.rouault@spatialys.com>
+Date: Sun, 31 Dec 2017 15:09:41 +0100
+Subject: [PATCH] libtiff/tif_print.c: TIFFPrintDirectory(): fix null pointer
+ dereference on corrupted file. Fixes
+ http://bugzilla.maptools.org/show_bug.cgi?id=2770
+
+---
+ libtiff/tif_print.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/libtiff/tif_print.c b/libtiff/tif_print.c
+index 9959d353b1f9..8deceb2b054d 100644
+--- a/libtiff/tif_print.c
++++ b/libtiff/tif_print.c
+@@ -665,13 +665,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
+ #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
+ 			fprintf(fd, "    %3lu: [%8I64u, %8I64u]\n",
+ 			    (unsigned long) s,
+-			    (unsigned __int64) td->td_stripoffset[s],
+-			    (unsigned __int64) td->td_stripbytecount[s]);
++			    td->td_stripoffset ? (unsigned __int64) td->td_stripoffset[s] : 0,
++			    td->td_stripbytecount ? (unsigned __int64) td->td_stripbytecount[s] : 0);
+ #else
+ 			fprintf(fd, "    %3lu: [%8llu, %8llu]\n",
+ 			    (unsigned long) s,
+-			    (unsigned long long) td->td_stripoffset[s],
+-			    (unsigned long long) td->td_stripbytecount[s]);
++			    td->td_stripoffset ? (unsigned long long) td->td_stripoffset[s] : 0,
++			    td->td_stripbytecount ? (unsigned long long) td->td_stripbytecount[s] : 0);
+ #endif
+ 	}
+ }
+-- 
+2.16.1
+

diff --git a/media-libs/tiff/tiff-4.0.9-r4.ebuild b/media-libs/tiff/tiff-4.0.9-r4.ebuild
new file mode 100644
index 00000000000..4787ecd348e
--- /dev/null
+++ b/media-libs/tiff/tiff-4.0.9-r4.ebuild
@@ -0,0 +1,81 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="6"
+
+inherit autotools libtool ltprune multilib-minimal
+
+DESCRIPTION="Tag Image File Format (TIFF) library"
+HOMEPAGE="http://libtiff.maptools.org"
+SRC_URI="http://download.osgeo.org/libtiff/${P}.tar.gz
+	ftp://ftp.remotesensing.org/pub/libtiff/${P}.tar.gz"
+
+LICENSE="libtiff"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~x64-solaris ~x86-solaris"
+IUSE="+cxx jbig jpeg lzma static-libs test zlib"
+
+RDEPEND="jpeg? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
+	jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
+	lzma? ( >=app-arch/xz-utils-5.0.5-r1:=[${MULTILIB_USEDEP}] )
+	zlib? ( >=sys-libs/zlib-1.2.8-r1:=[${MULTILIB_USEDEP}] )"
+DEPEND="${RDEPEND}"
+
+REQUIRED_USE="test? ( jpeg )" #483132
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0008-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
+	"${FILESDIR}"/${P}-CVE-2017-9935.patch #624696
+	"${FILESDIR}"/${P}-CVE-2017-9935-fix-incorrect-type.patch #624696
+	"${FILESDIR}"/${P}-CVE-2017-18013.patch #645982
+	"${FILESDIR}"/${P}-CVE-2018-5784.patch #645730
+)
+
+MULTILIB_WRAPPED_HEADERS=(
+	/usr/include/tiffconf.h
+)
+
+src_prepare() {
+	default
+
+	# tiffcp-thumbnail.sh fails as thumbnail binary doesn't get built anymore since tiff-4.0.7
+	sed '/tiffcp-thumbnail\.sh/d' -i test/Makefile.am || die
+
+	eautoreconf
+}
+
+multilib_src_configure() {
+	local myeconfargs=(
+		--without-x
+		$(use_enable cxx)
+		$(use_enable jbig)
+		$(use_enable jpeg)
+		$(use_enable lzma)
+		$(use_enable static-libs static)
+		$(use_enable zlib)
+	)
+	ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+
+	# remove useless subdirs
+	if ! multilib_is_native_abi ; then
+		sed -i \
+			-e 's/ tools//' \
+			-e 's/ contrib//' \
+			-e 's/ man//' \
+			-e 's/ html//' \
+			Makefile || die
+	fi
+}
+
+multilib_src_test() {
+	if ! multilib_is_native_abi ; then
+		emake -C tools
+	fi
+	emake check
+}
+
+multilib_src_install_all() {
+	prune_libtool_files --all
+	rm -f "${ED%/}"/usr/share/doc/${PF}/{COPYRIGHT,README*,RELEASE-DATE,TODO,VERSION}
+}


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/
@ 2019-08-05  0:12 Aaron Bauman
  0 siblings, 0 replies; 13+ messages in thread
From: Aaron Bauman @ 2019-08-05  0:12 UTC (permalink / raw
  To: gentoo-commits

commit:     1408d12740a4cd2a6d71fe5f52386d9d77128645
Author:     Aaron Bauman <bman <AT> gentoo <DOT> org>
AuthorDate: Mon Aug  5 00:03:19 2019 +0000
Commit:     Aaron Bauman <bman <AT> gentoo <DOT> org>
CommitDate: Mon Aug  5 00:12:00 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1408d127

media-libs/tiff: revbump to address open security bugs

* This commit addresses 3 outstanding security issues reported by the
individuals listed below.

* This commit involved cherry-picking the patches and adding a revbump as
the original PR's renamed the original ebuild and kept stable keywords.

Bug: https://bugs.gentoo.org/639700
Bug: https://bugs.gentoo.org/690732

Closes: https://github.com/gentoo/gentoo/pull/12543
Closes: https://github.com/gentoo/gentoo/pull/11743

Reported-by: Benjamin Gordon <bmgordon <AT> chromium.org>
Reported-by: Allen Webb <allenwebb <AT> google.com>
Signed-off-by: Aaron Bauman <bman <AT> gentoo.org>

 ...-2018-17000-tif_dirwrite-null-dereference.patch | 33 +++++++++
 .../tiff-4.0.10-CVE-2019-6128-pal2rgb-leak.patch   | 48 ++++++++++++
 ....0.10-CVE-2019-7663-tiffcpIntegerOverflow.patch | 73 ++++++++++++++++++
 media-libs/tiff/tiff-4.0.10-r1.ebuild              | 86 ++++++++++++++++++++++
 4 files changed, 240 insertions(+)

diff --git a/media-libs/tiff/files/tiff-4.0.10-CVE-2018-17000-tif_dirwrite-null-dereference.patch b/media-libs/tiff/files/tiff-4.0.10-CVE-2018-17000-tif_dirwrite-null-dereference.patch
new file mode 100644
index 00000000000..321c6a428af
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.10-CVE-2018-17000-tif_dirwrite-null-dereference.patch
@@ -0,0 +1,33 @@
+https://crbug.com/901306
+
+commit 802d3cbf3043be5dce5317e140ccb1c17a6a2d39
+Author: Thomas Bernard <miniupnp@free.fr>
+Date:   Tue Jan 29 11:21:47 2019 +0100
+
+    TIFFWriteDirectoryTagTransferfunction() : fix NULL dereferencing
+
+    http://bugzilla.maptools.org/show_bug.cgi?id=2833
+
+    we must check the pointer is not NULL before memcmp() the memory
+
+diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
+index c15a28dbd8fcb99b81fa5a1d44fcbcda881f42a7..ef30c869d30e210d90be16ce91f44087925fbad3 100644
+--- a/libtiff/tif_dirwrite.c
++++ b/libtiff/tif_dirwrite.c
+@@ -1893,12 +1893,14 @@ TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32* ndir, TIFFDirEntry* dir
+ 		n=3;
+ 	if (n==3)
+ 	{
+-		if (!_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[2],m*sizeof(uint16)))
++		if (tif->tif_dir.td_transferfunction[2] == NULL ||
++		    !_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[2],m*sizeof(uint16)))
+ 			n=2;
+ 	}
+ 	if (n==2)
+ 	{
+-		if (!_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[1],m*sizeof(uint16)))
++		if (tif->tif_dir.td_transferfunction[1] == NULL ||
++		    !_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[1],m*sizeof(uint16)))
+ 			n=1;
+ 	}
+ 	if (n==0)

diff --git a/media-libs/tiff/files/tiff-4.0.10-CVE-2019-6128-pal2rgb-leak.patch b/media-libs/tiff/files/tiff-4.0.10-CVE-2019-6128-pal2rgb-leak.patch
new file mode 100644
index 00000000000..38d020fec24
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.10-CVE-2019-6128-pal2rgb-leak.patch
@@ -0,0 +1,48 @@
+https://crbug.com/923647
+
+commit ae0bed1fe530a82faf2e9ea1775109dbf301a971
+Merge: 933784a1 0c74a9f4
+Author: Even Rouault <even.rouault@spatialys.com>
+Date:   Sat Feb 2 14:46:05 2019 +0000
+
+    Merge branch 'master' into 'master'
+
+    Fix for simple memory leak that was assigned CVE-2019-6128.
+
+    See merge request libtiff/libtiff!50
+
+diff --git a/tools/pal2rgb.c b/tools/pal2rgb.c
+index 01d8502ecf7a8a7f015e49ca9378a1a741cbc06b..9492f1cf1212177bf7e97d307757d0977c898e90 100644
+--- a/tools/pal2rgb.c
++++ b/tools/pal2rgb.c
+@@ -118,12 +118,14 @@ main(int argc, char* argv[])
+ 	    shortv != PHOTOMETRIC_PALETTE) {
+ 		fprintf(stderr, "%s: Expecting a palette image.\n",
+ 		    argv[optind]);
++		(void) TIFFClose(in);
+ 		return (-1);
+ 	}
+ 	if (!TIFFGetField(in, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) {
+ 		fprintf(stderr,
+ 		    "%s: No colormap (not a valid palette image).\n",
+ 		    argv[optind]);
++		(void) TIFFClose(in);
+ 		return (-1);
+ 	}
+ 	bitspersample = 0;
+@@ -131,11 +133,14 @@ main(int argc, char* argv[])
+ 	if (bitspersample != 8) {
+ 		fprintf(stderr, "%s: Sorry, can only handle 8-bit images.\n",
+ 		    argv[optind]);
++		(void) TIFFClose(in);
+ 		return (-1);
+ 	}
+ 	out = TIFFOpen(argv[optind+1], "w");
+-	if (out == NULL)
++	if (out == NULL) {
++		(void) TIFFClose(in);
+ 		return (-2);
++	}
+ 	cpTags(in, out);
+ 	TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &imagewidth);
+ 	TIFFGetField(in, TIFFTAG_IMAGELENGTH, &imagelength);

diff --git a/media-libs/tiff/files/tiff-4.0.10-CVE-2019-7663-tiffcpIntegerOverflow.patch b/media-libs/tiff/files/tiff-4.0.10-CVE-2019-7663-tiffcpIntegerOverflow.patch
new file mode 100644
index 00000000000..a68ba2f4bbd
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.10-CVE-2019-7663-tiffcpIntegerOverflow.patch
@@ -0,0 +1,73 @@
+From 2b0d0e699730d1f26bbeba8397bfdf0e9e01e59d Mon Sep 17 00:00:00 2001
+From: Thomas Bernard <miniupnp@free.fr>
+Date: Mon, 11 Feb 2019 10:05:33 +0100
+Subject: [PATCH 1/2] check that (Tile Width)*(Samples/Pixel) do no overflow
+
+fixes bug 2833
+---
+ tools/tiffcp.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/tools/tiffcp.c b/tools/tiffcp.c
+index 2f406e2d7..f0ee2c029 100644
+--- a/tools/tiffcp.c
++++ b/tools/tiffcp.c
+@@ -1408,7 +1408,7 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
+ 	int status = 1;
+ 	uint32 imagew = TIFFRasterScanlineSize(in);
+ 	uint32 tilew = TIFFTileRowSize(in);
+-	int iskew  = imagew - tilew*spp;
++	int iskew;
+ 	tsize_t tilesize = TIFFTileSize(in);
+ 	tdata_t tilebuf;
+ 	uint8* bufp = (uint8*) buf;
+@@ -1416,6 +1416,12 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
+ 	uint32 row;
+ 	uint16 bps = 0, bytes_per_sample;
+ 
++	if (spp > (0x7fffffff / tilew))
++	{
++		TIFFError(TIFFFileName(in), "Error, cannot handle that much samples per tile row (Tile Width * Samples/Pixel)");
++		return 0;
++	}
++	iskew = imagew - tilew*spp;
+ 	tilebuf = _TIFFmalloc(tilesize);
+ 	if (tilebuf == 0)
+ 		return 0;
+-- 
+2.21.0
+
+
+From 7cc76e9bc40bc8eb329a718ab26ecef7dd1afd94 Mon Sep 17 00:00:00 2001
+From: Thomas Bernard <miniupnp@free.fr>
+Date: Mon, 11 Feb 2019 21:42:03 +0100
+Subject: [PATCH 2/2] tiffcp.c: use INT_MAX
+
+---
+ tools/tiffcp.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/tools/tiffcp.c b/tools/tiffcp.c
+index f0ee2c029..8c81aa4f2 100644
+--- a/tools/tiffcp.c
++++ b/tools/tiffcp.c
+@@ -41,6 +41,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <limits.h>
+ 
+ #include <ctype.h>
+ 
+@@ -1416,7 +1417,7 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
+ 	uint32 row;
+ 	uint16 bps = 0, bytes_per_sample;
+ 
+-	if (spp > (0x7fffffff / tilew))
++	if (spp > (INT_MAX / tilew))
+ 	{
+ 		TIFFError(TIFFFileName(in), "Error, cannot handle that much samples per tile row (Tile Width * Samples/Pixel)");
+ 		return 0;
+-- 
+2.21.0
+

diff --git a/media-libs/tiff/tiff-4.0.10-r1.ebuild b/media-libs/tiff/tiff-4.0.10-r1.ebuild
new file mode 100644
index 00000000000..638c7c39917
--- /dev/null
+++ b/media-libs/tiff/tiff-4.0.10-r1.ebuild
@@ -0,0 +1,86 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit autotools libtool multilib-minimal
+
+DESCRIPTION="Tag Image File Format (TIFF) library"
+HOMEPAGE="http://libtiff.maptools.org"
+SRC_URI="https://download.osgeo.org/libtiff/${P}.tar.gz"
+
+LICENSE="libtiff"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="+cxx jbig jpeg lzma static-libs test webp zlib zstd"
+
+RDEPEND="
+	jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
+	jpeg? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
+	lzma? ( >=app-arch/xz-utils-5.0.5-r1[${MULTILIB_USEDEP}] )
+	webp? ( media-libs/libwebp:=[${MULTILIB_USEDEP}] )
+	zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )
+	zstd? ( >=app-arch/zstd-1.3.7-r1:=[${MULTILIB_USEDEP}] )
+"
+DEPEND="${RDEPEND}"
+
+REQUIRED_USE="test? ( jpeg )" #483132
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
+	"${FILESDIR}"/${PN}-4.0.7-pdfium-0008-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
+	"${FILESDIR}"/${PN}-4.0.10-CVE-2018-17000-tif_dirwrite-null-dereference.patch
+	"${FILESDIR}"/${PN}-4.0.10-CVE-2019-6128-pal2rgb-leak.patch
+	"${FILESDIR}"/${PN}-4.0.10-CVE-2019-7663-tiffcpIntegerOverflow.patch
+)
+
+MULTILIB_WRAPPED_HEADERS=(
+	/usr/include/tiffconf.h
+)
+
+src_prepare() {
+	default
+
+	# tiffcp-thumbnail.sh fails as thumbnail binary doesn't get built anymore since tiff-4.0.7
+	sed '/tiffcp-thumbnail\.sh/d' -i test/Makefile.am || die
+
+	eautoreconf
+}
+
+multilib_src_configure() {
+	local myeconfargs=(
+		--without-x
+		--with-docdir="${EPREFIX}"/usr/share/doc/${PF}
+		$(use_enable cxx)
+		$(use_enable jbig)
+		$(use_enable jpeg)
+		$(use_enable lzma)
+		$(use_enable static-libs static)
+		$(use_enable webp)
+		$(use_enable zlib)
+		$(use_enable zstd)
+	)
+	ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+
+	# remove useless subdirs
+	if ! multilib_is_native_abi ; then
+		sed -i \
+			-e 's/ tools//' \
+			-e 's/ contrib//' \
+			-e 's/ man//' \
+			-e 's/ html//' \
+			Makefile || die
+	fi
+}
+
+multilib_src_test() {
+	if ! multilib_is_native_abi ; then
+		emake -C tools
+	fi
+	emake check
+}
+
+multilib_src_install_all() {
+	find "${ED}" -name '*.la' -delete || die
+	rm "${ED}"/usr/share/doc/${PF}/{COPYRIGHT,README*,RELEASE-DATE,TODO,VERSION} || die
+}


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/
@ 2019-09-03 19:46 Aaron Bauman
  0 siblings, 0 replies; 13+ messages in thread
From: Aaron Bauman @ 2019-09-03 19:46 UTC (permalink / raw
  To: gentoo-commits

commit:     6f50c6e9a116c3d950db0cd2e131893aca2f1cf2
Author:     Mattias Nissler <mnissler <AT> chromium <DOT> org>
AuthorDate: Tue Sep  3 10:25:18 2019 +0000
Commit:     Aaron Bauman <bman <AT> gentoo <DOT> org>
CommitDate: Tue Sep  3 19:45:36 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6f50c6e9

media-libs/tiff: Pull in patch for CVE-2019-14973

Bug: https://bugs.gentoo.org/693394

Signed-off-by: Mattias Nissler <mnissler <AT> chromium.org>
Closes: https://github.com/gentoo/gentoo/pull/12851
Signed-off-by: Aaron Bauman <bman <AT> gentoo.org>

 ....0.10-CVE-2019-14973-fix-integer-overflow.patch | 395 +++++++++++++++++++++
 media-libs/tiff/tiff-4.0.10-r2.ebuild              |  85 +++++
 2 files changed, 480 insertions(+)

diff --git a/media-libs/tiff/files/tiff-4.0.10-CVE-2019-14973-fix-integer-overflow.patch b/media-libs/tiff/files/tiff-4.0.10-CVE-2019-14973-fix-integer-overflow.patch
new file mode 100644
index 00000000000..cbcbfd9d7f0
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.0.10-CVE-2019-14973-fix-integer-overflow.patch
@@ -0,0 +1,395 @@
+From 6ebfcac47224d3b8661c501967d495135449883e Mon Sep 17 00:00:00 2001
+From: Even Rouault <even.rouault@spatialys.com>
+Date: Sat, 10 Aug 2019 18:25:03 +0200
+Subject: [PATCH] Fix integer overflow in _TIFFCheckMalloc() and other
+ implementation-defined behaviour (CVE-2019-14973)
+
+_TIFFCheckMalloc()/_TIFFCheckRealloc() used a unsafe way to detect overflow
+in the multiplication of nmemb and elem_size (which are of type tmsize_t, thus
+signed), which was especially easily triggered on 32-bit builds (with recent
+enough compilers that assume that signed multiplication cannot overflow, since
+this is undefined behaviour by the C standard). The original issue which lead to
+this fix was trigged from tif_fax3.c
+
+There were also unsafe (implementation defied), and broken in practice on 64bit
+builds, ways of checking that a uint64 fits of a (signed) tmsize_t by doing
+(uint64)(tmsize_t)uint64_var != uint64_var comparisons. Those have no known
+at that time exploits, but are better to fix in a more bullet-proof way.
+Or similarly use of (int64)uint64_var <= 0.
+
+--- a/libtiff/tif_aux.c
++++ b/libtiff/tif_aux.c
+@@ -57,18 +57,57 @@ _TIFFMultiply64(TIFF* tif, uint64 first, uint64 second, const char* where)
+ 	return bytes;
+ }
+ 
++tmsize_t
++_TIFFMultiplySSize(TIFF* tif, tmsize_t first, tmsize_t second, const char* where)
++{
++    if( first <= 0 || second <= 0 )
++    {
++        if( tif != NULL && where != NULL )
++        {
++            TIFFErrorExt(tif->tif_clientdata, where,
++                        "Invalid argument to _TIFFMultiplySSize() in %s", where);
++        }
++        return 0;
++    }
++
++    if( first > TIFF_TMSIZE_T_MAX / second )
++    {
++        if( tif != NULL && where != NULL )
++        {
++            TIFFErrorExt(tif->tif_clientdata, where,
++                        "Integer overflow in %s", where);
++        }
++        return 0;
++    }
++    return first * second;
++}
++
++tmsize_t _TIFFCastUInt64ToSSize(TIFF* tif, uint64 val, const char* module)
++{
++    if( val > (uint64)TIFF_TMSIZE_T_MAX )
++    {
++        if( tif != NULL && module != NULL )
++        {
++            TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
++        }
++        return 0;
++    }
++    return (tmsize_t)val;
++}
++
+ void*
+ _TIFFCheckRealloc(TIFF* tif, void* buffer,
+ 		  tmsize_t nmemb, tmsize_t elem_size, const char* what)
+ {
+ 	void* cp = NULL;
+-	tmsize_t bytes = nmemb * elem_size;
+-
++        tmsize_t count = _TIFFMultiplySSize(tif, nmemb, elem_size, NULL);
+ 	/*
+-	 * XXX: Check for integer overflow.
++	 * Check for integer overflow.
+ 	 */
+-	if (nmemb && elem_size && bytes / elem_size == nmemb)
+-		cp = _TIFFrealloc(buffer, bytes);
++	if (count != 0)
++	{
++		cp = _TIFFrealloc(buffer, count);
++	}
+ 
+ 	if (cp == NULL) {
+ 		TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
+--- a/libtiff/tif_getimage.c
++++ b/libtiff/tif_getimage.c
+@@ -755,9 +755,8 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
+ 	uint32 leftmost_tw;
+ 
+ 	tilesize = TIFFTileSize(tif);  
+-	bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,tilesize);
++	bufsize = _TIFFMultiplySSize(tif, alpha?4:3,tilesize, "gtTileSeparate");
+ 	if (bufsize == 0) {
+-		TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtTileSeparate");
+ 		return (0);
+ 	}
+ 
+@@ -1019,9 +1018,8 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
+         uint16 colorchannels;
+ 
+ 	stripsize = TIFFStripSize(tif);  
+-	bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,stripsize);
++	bufsize = _TIFFMultiplySSize(tif,alpha?4:3,stripsize, "gtStripSeparate");
+ 	if (bufsize == 0) {
+-		TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtStripSeparate");
+ 		return (0);
+ 	}
+ 
+--- a/libtiff/tif_luv.c
++++ b/libtiff/tif_luv.c
+@@ -1264,16 +1264,10 @@ LogL16GuessDataFmt(TIFFDirectory *td)
+ 	return (SGILOGDATAFMT_UNKNOWN);
+ }
+ 
+-
+-#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0))
+-#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1)
+-
+ static tmsize_t
+ multiply_ms(tmsize_t m1, tmsize_t m2)
+ {
+-        if( m1 == 0 || m2 > TIFF_TMSIZE_T_MAX / m1 )
+-            return 0;
+-        return m1 * m2;
++        return _TIFFMultiplySSize(NULL, m1, m2, NULL);
+ }
+ 
+ static int
+--- a/libtiff/tif_pixarlog.c
++++ b/libtiff/tif_pixarlog.c
+@@ -634,15 +634,10 @@ PixarLogGuessDataFmt(TIFFDirectory *td)
+ 	return guess;
+ }
+ 
+-#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0))
+-#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1)
+-
+ static tmsize_t
+ multiply_ms(tmsize_t m1, tmsize_t m2)
+ {
+-        if( m1 == 0 || m2 > TIFF_TMSIZE_T_MAX / m1 )
+-            return 0;
+-        return m1 * m2;
++        return _TIFFMultiplySSize(NULL, m1, m2, NULL);
+ }
+ 
+ static tmsize_t
+--- a/libtiff/tif_read.c
++++ b/libtiff/tif_read.c
+@@ -29,9 +29,6 @@
+ #include "tiffiop.h"
+ #include <stdio.h>
+ 
+-#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0))
+-#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1)
+-
+ int TIFFFillStrip(TIFF* tif, uint32 strip);
+ int TIFFFillTile(TIFF* tif, uint32 tile);
+ static int TIFFStartStrip(TIFF* tif, uint32 strip);
+@@ -49,6 +46,8 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m
+ #define THRESHOLD_MULTIPLIER 10
+ #define MAX_THRESHOLD (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * INITIAL_THRESHOLD)
+ 
++#define TIFF_INT64_MAX ((((int64)0x7FFFFFFF) << 32) | 0xFFFFFFFF)
++
+ /* Read 'size' bytes in tif_rawdata buffer starting at offset 'rawdata_offset'
+  * Returns 1 in case of success, 0 otherwise. */
+ static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size,
+@@ -734,23 +733,8 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
+ 		return ((tmsize_t)(-1));
+ 	}
+ 	bytecount = td->td_stripbytecount[strip];
+-	if ((int64)bytecount <= 0) {
+-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
+-		TIFFErrorExt(tif->tif_clientdata, module,
+-			     "%I64u: Invalid strip byte count, strip %lu",
+-			     (unsigned __int64) bytecount,
+-			     (unsigned long) strip);
+-#else
+-		TIFFErrorExt(tif->tif_clientdata, module,
+-			     "%llu: Invalid strip byte count, strip %lu",
+-			     (unsigned long long) bytecount,
+-			     (unsigned long) strip);
+-#endif
+-		return ((tmsize_t)(-1));
+-	}
+-	bytecountm = (tmsize_t)bytecount;
+-	if ((uint64)bytecountm!=bytecount) {
+-		TIFFErrorExt(tif->tif_clientdata, module, "Integer overflow");
++        bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount, module);
++	if (bytecountm == 0) {
+ 		return ((tmsize_t)(-1));
+ 	}
+ 	if (size != (tmsize_t)(-1) && size < bytecountm)
+@@ -774,7 +758,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
+ 	if ((tif->tif_flags&TIFF_NOREADRAW)==0)
+ 	{
+ 		uint64 bytecount = td->td_stripbytecount[strip];
+-		if ((int64)bytecount <= 0) {
++		if( bytecount == 0 || bytecount > (uint64)TIFF_INT64_MAX ) {
+ #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
+ 			TIFFErrorExt(tif->tif_clientdata, module,
+ 				"Invalid strip byte count %I64u, strip %lu",
+@@ -801,7 +785,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
+ 			    (bytecount - 4096) / 10 > (uint64)stripsize  )
+ 			{
+ 				uint64 newbytecount = (uint64)stripsize * 10 + 4096;
+-				if( (int64)newbytecount >= 0 )
++				if( newbytecount == 0 || newbytecount > (uint64)TIFF_INT64_MAX )
+ 				{
+ #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
+ 					TIFFWarningExt(tif->tif_clientdata, module,
+@@ -1196,10 +1180,8 @@ TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size)
+ 	bytecount64 = td->td_stripbytecount[tile];
+ 	if (size != (tmsize_t)(-1) && (uint64)size < bytecount64)
+ 		bytecount64 = (uint64)size;
+-	bytecountm = (tmsize_t)bytecount64;
+-	if ((uint64)bytecountm!=bytecount64)
+-	{
+-		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
++	bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module);
++        if( bytecountm == 0 ) {
+ 		return ((tmsize_t)(-1));
+ 	}
+ 	return (TIFFReadRawTile1(tif, tile, buf, bytecountm, module));
+@@ -1221,7 +1203,7 @@ TIFFFillTile(TIFF* tif, uint32 tile)
+ 	if ((tif->tif_flags&TIFF_NOREADRAW)==0)
+ 	{
+ 		uint64 bytecount = td->td_stripbytecount[tile];
+-		if ((int64)bytecount <= 0) {
++		if( bytecount == 0 || bytecount > (uint64)TIFF_INT64_MAX ) {
+ #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
+ 			TIFFErrorExt(tif->tif_clientdata, module,
+ 				"%I64u: Invalid tile byte count, tile %lu",
+@@ -1248,7 +1230,7 @@ TIFFFillTile(TIFF* tif, uint32 tile)
+ 			    (bytecount - 4096) / 10 > (uint64)stripsize  )
+ 			{
+ 				uint64 newbytecount = (uint64)stripsize * 10 + 4096;
+-				if( (int64)newbytecount >= 0 )
++				if( newbytecount == 0 || newbytecount > (uint64)TIFF_INT64_MAX )
+ 				{
+ #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
+ 					TIFFWarningExt(tif->tif_clientdata, module,
+--- a/libtiff/tif_strip.c
++++ b/libtiff/tif_strip.c
+@@ -129,15 +129,8 @@ TIFFVStripSize(TIFF* tif, uint32 nrows)
+ {
+ 	static const char module[] = "TIFFVStripSize";
+ 	uint64 m;
+-	tmsize_t n;
+ 	m=TIFFVStripSize64(tif,nrows);
+-	n=(tmsize_t)m;
+-	if ((uint64)n!=m)
+-	{
+-		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
+-		n=0;
+-	}
+-	return(n);
++        return _TIFFCastUInt64ToSSize(tif, m, module);
+ }
+ 
+ /*
+@@ -211,15 +204,8 @@ TIFFStripSize(TIFF* tif)
+ {
+ 	static const char module[] = "TIFFStripSize";
+ 	uint64 m;
+-	tmsize_t n;
+ 	m=TIFFStripSize64(tif);
+-	n=(tmsize_t)m;
+-	if ((uint64)n!=m)
+-	{
+-		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
+-		n=0;
+-	}
+-	return(n);
++	return _TIFFCastUInt64ToSSize(tif, m, module);
+ }
+ 
+ /*
+@@ -330,14 +316,8 @@ TIFFScanlineSize(TIFF* tif)
+ {
+ 	static const char module[] = "TIFFScanlineSize";
+ 	uint64 m;
+-	tmsize_t n;
+ 	m=TIFFScanlineSize64(tif);
+-	n=(tmsize_t)m;
+-	if ((uint64)n!=m) {
+-		TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow");
+-		n=0;
+-	}
+-	return(n);
++	return _TIFFCastUInt64ToSSize(tif, m, module);
+ }
+ 
+ /*
+@@ -366,15 +346,8 @@ TIFFRasterScanlineSize(TIFF* tif)
+ {
+ 	static const char module[] = "TIFFRasterScanlineSize";
+ 	uint64 m;
+-	tmsize_t n;
+ 	m=TIFFRasterScanlineSize64(tif);
+-	n=(tmsize_t)m;
+-	if ((uint64)n!=m)
+-	{
+-		TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow");
+-		n=0;
+-	}
+-	return(n);
++	return _TIFFCastUInt64ToSSize(tif, m, module);
+ }
+ 
+ /* vim: set ts=8 sts=8 sw=8 noet: */
+--- a/libtiff/tif_tile.c
++++ b/libtiff/tif_tile.c
+@@ -181,15 +181,8 @@ TIFFTileRowSize(TIFF* tif)
+ {
+ 	static const char module[] = "TIFFTileRowSize";
+ 	uint64 m;
+-	tmsize_t n;
+ 	m=TIFFTileRowSize64(tif);
+-	n=(tmsize_t)m;
+-	if ((uint64)n!=m)
+-	{
+-		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
+-		n=0;
+-	}
+-	return(n);
++	return _TIFFCastUInt64ToSSize(tif, m, module);
+ }
+ 
+ /*
+@@ -248,15 +241,8 @@ TIFFVTileSize(TIFF* tif, uint32 nrows)
+ {
+ 	static const char module[] = "TIFFVTileSize";
+ 	uint64 m;
+-	tmsize_t n;
+ 	m=TIFFVTileSize64(tif,nrows);
+-	n=(tmsize_t)m;
+-	if ((uint64)n!=m)
+-	{
+-		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
+-		n=0;
+-	}
+-	return(n);
++	return _TIFFCastUInt64ToSSize(tif, m, module);
+ }
+ 
+ /*
+@@ -272,15 +258,8 @@ TIFFTileSize(TIFF* tif)
+ {
+ 	static const char module[] = "TIFFTileSize";
+ 	uint64 m;
+-	tmsize_t n;
+ 	m=TIFFTileSize64(tif);
+-	n=(tmsize_t)m;
+-	if ((uint64)n!=m)
+-	{
+-		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
+-		n=0;
+-	}
+-	return(n);
++	return _TIFFCastUInt64ToSSize(tif, m, module);
+ }
+ 
+ /*
+--- a/libtiff/tiffiop.h
++++ b/libtiff/tiffiop.h
+@@ -77,6 +77,9 @@ extern int snprintf(char* str, size_t size, const char* format, ...);
+ #define	FALSE	0
+ #endif
+ 
++#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0))
++#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1)
++
+ typedef struct client_info {
+     struct client_info *next;
+     void *data;
+@@ -258,7 +261,7 @@ struct tiff {
+ #define TIFFhowmany8_64(x) (((x)&0x07)?((uint64)(x)>>3)+1:(uint64)(x)>>3)
+ #define TIFFroundup_64(x, y) (TIFFhowmany_64(x,y)*(y))
+ 
+-/* Safe multiply which returns zero if there is an integer overflow */
++/* Safe multiply which returns zero if there is an *unsigned* integer overflow. This macro is not safe for *signed* integer types */
+ #define TIFFSafeMultiply(t,v,m) ((((t)(m) != (t)0) && (((t)(((v)*(m))/(m))) == (t)(v))) ? (t)((v)*(m)) : (t)0)
+ 
+ #define TIFFmax(A,B) ((A)>(B)?(A):(B))
+@@ -368,6 +371,8 @@ extern TIFFErrorHandlerExt _TIFFerrorHandlerExt;
+ 
+ extern uint32 _TIFFMultiply32(TIFF*, uint32, uint32, const char*);
+ extern uint64 _TIFFMultiply64(TIFF*, uint64, uint64, const char*);
++extern tmsize_t _TIFFMultiplySSize(TIFF*, tmsize_t, tmsize_t, const char*);
++extern tmsize_t _TIFFCastUInt64ToSSize(TIFF*, uint64, const char*);
+ extern void* _TIFFCheckMalloc(TIFF*, tmsize_t, tmsize_t, const char*);
+ extern void* _TIFFCheckRealloc(TIFF*, void*, tmsize_t, tmsize_t, const char*);
+ 

diff --git a/media-libs/tiff/tiff-4.0.10-r2.ebuild b/media-libs/tiff/tiff-4.0.10-r2.ebuild
new file mode 100644
index 00000000000..1a5a5bbf526
--- /dev/null
+++ b/media-libs/tiff/tiff-4.0.10-r2.ebuild
@@ -0,0 +1,85 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit autotools libtool multilib-minimal
+
+DESCRIPTION="Tag Image File Format (TIFF) library"
+HOMEPAGE="http://libtiff.maptools.org"
+SRC_URI="https://download.osgeo.org/libtiff/${P}.tar.gz"
+
+LICENSE="libtiff"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="+cxx jbig jpeg lzma static-libs test webp zlib zstd"
+
+RDEPEND="
+	jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
+	jpeg? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
+	lzma? ( >=app-arch/xz-utils-5.0.5-r1[${MULTILIB_USEDEP}] )
+	webp? ( media-libs/libwebp:=[${MULTILIB_USEDEP}] )
+	zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )
+	zstd? ( >=app-arch/zstd-1.3.7-r1:=[${MULTILIB_USEDEP}] )
+"
+DEPEND="${RDEPEND}"
+
+REQUIRED_USE="test? ( jpeg )" #483132
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-4.0.10-CVE-2018-17000-tif_dirwrite-null-dereference.patch
+	"${FILESDIR}"/${PN}-4.0.10-CVE-2019-6128-pal2rgb-leak.patch
+	"${FILESDIR}"/${PN}-4.0.10-CVE-2019-7663-tiffcpIntegerOverflow.patch
+	"${FILESDIR}"/${P}-CVE-2019-14973-fix-integer-overflow.patch
+)
+
+MULTILIB_WRAPPED_HEADERS=(
+	/usr/include/tiffconf.h
+)
+
+src_prepare() {
+	default
+
+	# tiffcp-thumbnail.sh fails as thumbnail binary doesn't get built anymore since tiff-4.0.7
+	sed '/tiffcp-thumbnail\.sh/d' -i test/Makefile.am || die
+
+	eautoreconf
+}
+
+multilib_src_configure() {
+	local myeconfargs=(
+		--without-x
+		--with-docdir="${EPREFIX}"/usr/share/doc/${PF}
+		$(use_enable cxx)
+		$(use_enable jbig)
+		$(use_enable jpeg)
+		$(use_enable lzma)
+		$(use_enable static-libs static)
+		$(use_enable webp)
+		$(use_enable zlib)
+		$(use_enable zstd)
+	)
+	ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+
+	# remove useless subdirs
+	if ! multilib_is_native_abi ; then
+		sed -i \
+			-e 's/ tools//' \
+			-e 's/ contrib//' \
+			-e 's/ man//' \
+			-e 's/ html//' \
+			Makefile || die
+	fi
+}
+
+multilib_src_test() {
+	if ! multilib_is_native_abi ; then
+		emake -C tools
+	fi
+	emake check
+}
+
+multilib_src_install_all() {
+	find "${ED}" -name '*.la' -delete || die
+	rm "${ED}"/usr/share/doc/${PF}/{COPYRIGHT,README*,RELEASE-DATE,TODO,VERSION} || die
+}


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/
@ 2019-11-03 13:46 Mikle Kolyada
  0 siblings, 0 replies; 13+ messages in thread
From: Mikle Kolyada @ 2019-11-03 13:46 UTC (permalink / raw
  To: gentoo-commits

commit:     36b1b60543df094492afcbdea67a49a9157635d1
Author:     Mikle Kolyada <zlogene <AT> gentoo <DOT> org>
AuthorDate: Sun Nov  3 13:46:15 2019 +0000
Commit:     Mikle Kolyada <zlogene <AT> gentoo <DOT> org>
CommitDate: Sun Nov  3 13:46:15 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=36b1b605

media-libs/tiff: Drop insecure

Package-Manager: Portage-2.3.76, Repoman-2.3.16
Signed-off-by: Mikle Kolyada <zlogene <AT> gentoo.org>

 ...ferOverflow-ChopUpSingleUncompressedStrip.patch | 33 ---------
 ...ferOverflow-ChopUpSingleUncompressedStrip.patch | 26 -------
 media-libs/tiff/tiff-4.0.10-r1.ebuild              | 86 ----------------------
 media-libs/tiff/tiff-4.0.10.ebuild                 | 83 ---------------------
 4 files changed, 228 deletions(-)

diff --git a/media-libs/tiff/files/tiff-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch b/media-libs/tiff/files/tiff-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
deleted file mode 100644
index a45ee342f77..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-https://codereview.chromium.org/2284063002
-https://crbug.com/618267
-https://pdfium.googlesource.com/pdfium/+/master/libtiff/
-
-Author: tracy_jiang <tracy_jiang@foxitsoftware.com>
-Date:   Mon Aug 29 13:42:56 2016 -0700
-
-Fix for #618267. Adding a method to determine if multiplication has
-overflow.
-
---- a/libtiff/tif_aux.c
-+++ b/libtiff/tif_aux.c
-@@ -69,7 +69,7 @@ _TIFFCheckRealloc(TIFF* tif, void* buffer,
- 	/*
- 	 * XXX: Check for integer overflow.
- 	 */
--	if (nmemb && elem_size && bytes / elem_size == nmemb)
-+	if (nmemb && elem_size && !_TIFFIfMultiplicationOverflow(nmemb, elem_size))
- 		cp = _TIFFrealloc(buffer, bytes);
- 
- 	if (cp == NULL) {
---- a/libtiff/tiffiop.h
-+++ b/libtiff/tiffiop.h
-@@ -315,6 +315,9 @@ typedef size_t TIFFIOSize_t;
- #define _TIFF_off_t off_t
- #endif
- 
-+#include <limits.h>
-+#define _TIFFIfMultiplicationOverflow(op1, op2) ((op1) > SSIZE_MAX / (op2))
-+
- #if defined(__cplusplus)
- extern "C" {
- #endif

diff --git a/media-libs/tiff/files/tiff-4.0.7-pdfium-0008-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch b/media-libs/tiff/files/tiff-4.0.7-pdfium-0008-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
deleted file mode 100644
index 35f59b9bffd..00000000000
--- a/media-libs/tiff/files/tiff-4.0.7-pdfium-0008-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-https://codereview.chromium.org/2405693002
-https://crbug.com/654169
-https://pdfium.googlesource.com/pdfium/+/master/libtiff/
-
-Author: stackexploit <stackexploit@gmail.com>
-Date:   Mon Oct 10 10:58:25 2016 -0700
-
-libtiff: Prevent a buffer overflow in function ChopUpSingleUncompressedStrip.
-
-The patch (https://codereview.chromium.org/2284063002) for Issue 618267
-was insufficient. The integer overflow still could be triggered and could
-lead to heap buffer overflow.
-
-This CL strengthens integer overflow check in function _TIFFCheckRealloc.
-
---- a/libtiff/tif_aux.c
-+++ b/libtiff/tif_aux.c
-@@ -69,7 +69,7 @@ _TIFFCheckRealloc(TIFF* tif, void* buffer,
- 	/*
- 	 * XXX: Check for integer overflow.
- 	 */
--	if (nmemb && elem_size && !_TIFFIfMultiplicationOverflow(nmemb, elem_size))
-+	if (nmemb > 0 && elem_size > 0 && !_TIFFIfMultiplicationOverflow(nmemb, elem_size))
- 		cp = _TIFFrealloc(buffer, bytes);
- 
- 	if (cp == NULL) {

diff --git a/media-libs/tiff/tiff-4.0.10-r1.ebuild b/media-libs/tiff/tiff-4.0.10-r1.ebuild
deleted file mode 100644
index 3a79093c5f7..00000000000
--- a/media-libs/tiff/tiff-4.0.10-r1.ebuild
+++ /dev/null
@@ -1,86 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-inherit autotools libtool multilib-minimal
-
-DESCRIPTION="Tag Image File Format (TIFF) library"
-HOMEPAGE="http://libtiff.maptools.org"
-SRC_URI="https://download.osgeo.org/libtiff/${P}.tar.gz"
-
-LICENSE="libtiff"
-SLOT="0"
-KEYWORDS="alpha amd64 ~arm arm64 hppa ia64 ~m68k ~mips ppc ppc64 ~riscv s390 ~sh sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-IUSE="+cxx jbig jpeg lzma static-libs test webp zlib zstd"
-
-RDEPEND="
-	jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
-	jpeg? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
-	lzma? ( >=app-arch/xz-utils-5.0.5-r1[${MULTILIB_USEDEP}] )
-	webp? ( media-libs/libwebp:=[${MULTILIB_USEDEP}] )
-	zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )
-	zstd? ( >=app-arch/zstd-1.3.7-r1:=[${MULTILIB_USEDEP}] )
-"
-DEPEND="${RDEPEND}"
-
-REQUIRED_USE="test? ( jpeg )" #483132
-
-PATCHES=(
-	"${FILESDIR}"/${PN}-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
-	"${FILESDIR}"/${PN}-4.0.7-pdfium-0008-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
-	"${FILESDIR}"/${PN}-4.0.10-CVE-2018-17000-tif_dirwrite-null-dereference.patch
-	"${FILESDIR}"/${PN}-4.0.10-CVE-2019-6128-pal2rgb-leak.patch
-	"${FILESDIR}"/${PN}-4.0.10-CVE-2019-7663-tiffcpIntegerOverflow.patch
-)
-
-MULTILIB_WRAPPED_HEADERS=(
-	/usr/include/tiffconf.h
-)
-
-src_prepare() {
-	default
-
-	# tiffcp-thumbnail.sh fails as thumbnail binary doesn't get built anymore since tiff-4.0.7
-	sed '/tiffcp-thumbnail\.sh/d' -i test/Makefile.am || die
-
-	eautoreconf
-}
-
-multilib_src_configure() {
-	local myeconfargs=(
-		--without-x
-		--with-docdir="${EPREFIX}"/usr/share/doc/${PF}
-		$(use_enable cxx)
-		$(use_enable jbig)
-		$(use_enable jpeg)
-		$(use_enable lzma)
-		$(use_enable static-libs static)
-		$(use_enable webp)
-		$(use_enable zlib)
-		$(use_enable zstd)
-	)
-	ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
-
-	# remove useless subdirs
-	if ! multilib_is_native_abi ; then
-		sed -i \
-			-e 's/ tools//' \
-			-e 's/ contrib//' \
-			-e 's/ man//' \
-			-e 's/ html//' \
-			Makefile || die
-	fi
-}
-
-multilib_src_test() {
-	if ! multilib_is_native_abi ; then
-		emake -C tools
-	fi
-	emake check
-}
-
-multilib_src_install_all() {
-	find "${ED}" -name '*.la' -delete || die
-	rm "${ED}"/usr/share/doc/${PF}/{COPYRIGHT,README*,RELEASE-DATE,TODO,VERSION} || die
-}

diff --git a/media-libs/tiff/tiff-4.0.10.ebuild b/media-libs/tiff/tiff-4.0.10.ebuild
deleted file mode 100644
index afe7c58676b..00000000000
--- a/media-libs/tiff/tiff-4.0.10.ebuild
+++ /dev/null
@@ -1,83 +0,0 @@
-# Copyright 1999-2019 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-inherit autotools libtool multilib-minimal
-
-DESCRIPTION="Tag Image File Format (TIFF) library"
-HOMEPAGE="http://libtiff.maptools.org"
-SRC_URI="https://download.osgeo.org/libtiff/${P}.tar.gz"
-
-LICENSE="libtiff"
-SLOT="0"
-KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 ~riscv s390 sh sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-IUSE="+cxx jbig jpeg lzma static-libs test webp zlib zstd"
-
-RDEPEND="
-	jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
-	jpeg? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
-	lzma? ( >=app-arch/xz-utils-5.0.5-r1[${MULTILIB_USEDEP}] )
-	webp? ( media-libs/libwebp:=[${MULTILIB_USEDEP}] )
-	zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )
-	zstd? ( >=app-arch/zstd-1.3.7-r1:=[${MULTILIB_USEDEP}] )
-"
-DEPEND="${RDEPEND}"
-
-REQUIRED_USE="test? ( jpeg )" #483132
-
-PATCHES=(
-	"${FILESDIR}"/${PN}-4.0.7-pdfium-0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
-	"${FILESDIR}"/${PN}-4.0.7-pdfium-0008-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
-)
-
-MULTILIB_WRAPPED_HEADERS=(
-	/usr/include/tiffconf.h
-)
-
-src_prepare() {
-	default
-
-	# tiffcp-thumbnail.sh fails as thumbnail binary doesn't get built anymore since tiff-4.0.7
-	sed '/tiffcp-thumbnail\.sh/d' -i test/Makefile.am || die
-
-	eautoreconf
-}
-
-multilib_src_configure() {
-	local myeconfargs=(
-		--without-x
-		--with-docdir="${EPREFIX}"/usr/share/doc/${PF}
-		$(use_enable cxx)
-		$(use_enable jbig)
-		$(use_enable jpeg)
-		$(use_enable lzma)
-		$(use_enable static-libs static)
-		$(use_enable webp)
-		$(use_enable zlib)
-		$(use_enable zstd)
-	)
-	ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
-
-	# remove useless subdirs
-	if ! multilib_is_native_abi ; then
-		sed -i \
-			-e 's/ tools//' \
-			-e 's/ contrib//' \
-			-e 's/ man//' \
-			-e 's/ html//' \
-			Makefile || die
-	fi
-}
-
-multilib_src_test() {
-	if ! multilib_is_native_abi ; then
-		emake -C tools
-	fi
-	emake check
-}
-
-multilib_src_install_all() {
-	find "${ED}" -name '*.la' -delete || die
-	rm "${ED}"/usr/share/doc/${PF}/{COPYRIGHT,README*,RELEASE-DATE,TODO,VERSION} || die
-}


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/
@ 2022-12-01  7:17 Sam James
  0 siblings, 0 replies; 13+ messages in thread
From: Sam James @ 2022-12-01  7:17 UTC (permalink / raw
  To: gentoo-commits

commit:     33944343462c9aa5a0a23b4a296074d0bc62c5c2
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Dec  1 07:15:54 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Dec  1 07:16:56 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=33944343

media-libs/tiff: backport fix for hylafaxplus regression

Closes: https://bugs.gentoo.org/883641
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/tiff-4.4.0-hylafaxplus-regression.patch  |  34 +++++++
 media-libs/tiff/tiff-4.4.0-r2.ebuild               | 102 +++++++++++++++++++++
 2 files changed, 136 insertions(+)

diff --git a/media-libs/tiff/files/tiff-4.4.0-hylafaxplus-regression.patch b/media-libs/tiff/files/tiff-4.4.0-hylafaxplus-regression.patch
new file mode 100644
index 000000000000..c640f6e1b1a7
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.4.0-hylafaxplus-regression.patch
@@ -0,0 +1,34 @@
+https://bugs.gentoo.org/883641
+https://gitlab.com/libtiff/libtiff/-/issues/489
+https://gitlab.com/libtiff/libtiff/-/commit/72de8fd00be8a583a6b16cc0b700105020d249ba
+
+From 72de8fd00be8a583a6b16cc0b700105020d249ba Mon Sep 17 00:00:00 2001
+From: Even Rouault <even.rouault@spatialys.com>
+Date: Tue, 29 Nov 2022 14:57:27 +0100
+Subject: [PATCH] TIFFWriteRawStrip(): restore capabilities to append data in
+ the current strip (fixes #489)
+
+This fixes a regression of libtiff 4.4.0
+--- a/libtiff/tif_write.c
++++ b/libtiff/tif_write.c
+@@ -341,10 +341,13 @@ TIFFWriteRawStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc)
+ 			return ((tmsize_t) -1);
+ 	}
+ 
+-	tif->tif_curstrip = strip;
++    if (tif->tif_curstrip != strip)
++    {
++        tif->tif_curstrip = strip;
+ 
+-	/* this informs TIFFAppendToStrip() we have changed or reset strip */
+-	tif->tif_curoff = 0;
++        /* this informs TIFFAppendToStrip() we have changed or reset strip */
++        tif->tif_curoff = 0;
++    }
+ 
+         if (td->td_stripsperimage == 0) {
+                 TIFFErrorExtR(tif, module,"Zero strips per image");
+-- 
+GitLab
+
+

diff --git a/media-libs/tiff/tiff-4.4.0-r2.ebuild b/media-libs/tiff/tiff-4.4.0-r2.ebuild
new file mode 100644
index 000000000000..f485be1f583a
--- /dev/null
+++ b/media-libs/tiff/tiff-4.4.0-r2.ebuild
@@ -0,0 +1,102 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+QA_PKGCONFIG_VERSION="$(ver_cut 1-3)"
+
+# Release signer can vary per version but not clear if others will be doing
+# them in future, so gone with Even Rouault for now as he does other geosci
+# stuff too like PROJ, GDAL. Previous release manager of TIFF was
+# GraphicsMagick maintainer Bob Friesenhahn. Please be careful when verifying
+# who made releases.
+VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/rouault.asc
+inherit multilib-minimal verify-sig libtool flag-o-matic
+
+MY_P="${P/_rc/rc}"
+DESCRIPTION="Tag Image File Format (TIFF) library"
+HOMEPAGE="http://libtiff.maptools.org"
+SRC_URI="https://download.osgeo.org/libtiff/${MY_P}.tar.xz"
+SRC_URI+=" verify-sig? ( https://download.osgeo.org/libtiff/${MY_P}.tar.xz.sig )"
+S="${WORKDIR}/${PN}-$(ver_cut 1-3)"
+
+LICENSE="libtiff"
+SLOT="0"
+if [[ ${PV} != *_rc* ]] ; then
+	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+fi
+IUSE="+cxx jbig jpeg lzma static-libs test webp zlib zstd"
+RESTRICT="!test? ( test )"
+
+# bug #483132
+REQUIRED_USE="test? ( jpeg )"
+
+RDEPEND="jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
+	jpeg? ( media-libs/libjpeg-turbo:=[${MULTILIB_USEDEP}] )
+	lzma? ( >=app-arch/xz-utils-5.0.5-r1[${MULTILIB_USEDEP}] )
+	webp? ( media-libs/libwebp:=[${MULTILIB_USEDEP}] )
+	zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )
+	zstd? ( >=app-arch/zstd-1.3.7-r1:=[${MULTILIB_USEDEP}] )"
+DEPEND="${RDEPEND}"
+BDEPEND="verify-sig? ( sec-keys/openpgp-keys-evenrouault )"
+
+MULTILIB_WRAPPED_HEADERS=(
+	/usr/include/tiffconf.h
+)
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-4.4.0_rc1-skip-thumbnail-test.patch
+	"${FILESDIR}"/${P}-hylafaxplus-regression.patch
+)
+
+src_prepare() {
+	default
+
+	# Added to fix cross-compilation
+	elibtoolize
+}
+
+multilib_src_configure() {
+	append-lfs-flags
+
+	local myeconfargs=(
+		--without-x
+		--with-docdir="${EPREFIX}"/usr/share/doc/${PF}
+		$(use_enable cxx)
+		$(use_enable jbig)
+		$(use_enable jpeg)
+		$(use_enable lzma)
+		$(use_enable static-libs static)
+		$(use_enable webp)
+		$(use_enable zlib)
+		$(use_enable zstd)
+	)
+
+	ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+
+	# Remove components (like tools) that are irrelevant for the multilib
+	# build which we only want libraries for.
+	# TODO: upstream options to disable these properly
+	# https://gitlab.com/libtiff/libtiff/-/merge_requests/334
+	if ! multilib_is_native_abi ; then
+		sed -i \
+			-e 's/ tools//' \
+			-e 's/ contrib//' \
+			-e 's/ man//' \
+			-e 's/ html//' \
+			Makefile || die
+	fi
+}
+
+multilib_src_test() {
+	if ! multilib_is_native_abi ; then
+		emake -C tools
+	fi
+
+	emake check
+}
+
+multilib_src_install_all() {
+	find "${ED}" -type f -name '*.la' -delete || die
+	rm "${ED}"/usr/share/doc/${PF}/{COPYRIGHT,README*,RELEASE-DATE,TODO,VERSION} || die
+}


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/
@ 2022-12-10  4:10 Sam James
  0 siblings, 0 replies; 13+ messages in thread
From: Sam James @ 2022-12-10  4:10 UTC (permalink / raw
  To: gentoo-commits

commit:     d63be024fb77b02effd31c92cd79e55013118447
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 10 04:09:36 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Dec 10 04:09:36 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d63be024

media-libs/tiff: add 4.5.0_rc1 (unkeyworded)

Bug: https://bugs.gentoo.org/856478
Signed-off-by: Sam James <sam <AT> gentoo.org>

 media-libs/tiff/Manifest                           |  2 +
 .../tiff-4.5.0_rc1-skip-tools-tests-multilib.patch | 52 +++++++++++++
 media-libs/tiff/tiff-4.5.0_rc1.ebuild              | 89 ++++++++++++++++++++++
 3 files changed, 143 insertions(+)

diff --git a/media-libs/tiff/Manifest b/media-libs/tiff/Manifest
index acd45d9a7287..ddbf4132f425 100644
--- a/media-libs/tiff/Manifest
+++ b/media-libs/tiff/Manifest
@@ -1,2 +1,4 @@
 DIST tiff-4.4.0.tar.xz 1929292 BLAKE2B d05a2fb293557d1e7cdec116c65c8338d7714af7b6abd8dd3bb2b476d62e044adc7d6c298843649d63c6bc09f6ce4660ee23638f9beb716937ccf236c2829dcf SHA512 c9611faadc9b1199f3aba9a43bfa160c77c11558d1fa358b42115ed78db73c8387531c0668cc9021842c58f1c02f8d84264d3600e1039dfe6f866822ad91cff9
 DIST tiff-4.4.0.tar.xz.sig 310 BLAKE2B 00dc8ff9c232ec4cca8b294659e6379b9bb512b58cd3d2f9231e7c10111510ac56aff3c6fc133a47f9fafc27595e099297c25940414495d8ea7f5a75aa43e9d2 SHA512 4ffdcbf5a8ce4a3be543d0ad43101ddcdb6ef22c3da5768c86660a40cc0cab48032a65c5e7bb0667f43d55dad5aa09dc0df302e2f9dbc9f24b8ccac643a0408c
+DIST tiff-4.5.0rc1.tar.xz 2314664 BLAKE2B da6bdd79348a9626d8523903b43388cc963a86d8527ffb58fd8fcc09b1aae5d7317ccfcc8cf6b2515267b3b559d327db256303e70039b12552ae87c120ee7beb SHA512 244a98142f0d18eb5b531dceb265d2444021c628e886912dbfb33e1d23e5444e350b5487bd8f94e3fbafd993dcb5e490c6f78c1426601e903ad2bbe4bc41953c
+DIST tiff-4.5.0rc1.tar.xz.sig 310 BLAKE2B b1b7ecb1f04e446cf7622df0ecff1482ca6175f4206350e9698488e2aaca64112ff41adcd8c5b817efbea947ffaec54258f87c9e932badc3c7493391960dc715 SHA512 8b2cc1d0c01d4f40f1c4c0827dbb12508d533f6c98e59cb9876a33b89fd4bbbfc8ccced3f27536d3bc00b5ae286e6b919b1468462396da38112dfc34c4ade3e0

diff --git a/media-libs/tiff/files/tiff-4.5.0_rc1-skip-tools-tests-multilib.patch b/media-libs/tiff/files/tiff-4.5.0_rc1-skip-tools-tests-multilib.patch
new file mode 100644
index 000000000000..831afd287226
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.5.0_rc1-skip-tools-tests-multilib.patch
@@ -0,0 +1,52 @@
+https://gitlab.com/libtiff/libtiff/-/merge_requests/334
+
+From e7605b93b12c2bf3c864910c23ac976045b5a05a Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+Date: Sat, 21 May 2022 01:01:35 +0100
+Subject: [PATCH 1/2] test (autotools): skip script tests if tools aren't built
+
+In Gentoo, we avoid building the tools for multilib (32-bit, x86) builds on
+amd64/x86_64 because we only need the library to keep binary applications working.
+
+This causes a test failure in e.g. tiffcp-thumbnail.sh as the 'thumbnail'
+binary isn't built. Skip it if unavailable.
+
+Fixes: https://gitlab.com/libtiff/libtiff/-/issues/421
+--- a/test/Makefile.am
++++ b/test/Makefile.am
+@@ -55,13 +55,14 @@ XFAIL_TESTS =
+ CLEANFILES = test_packbits.tif o-*
+ 
+ if HAVE_JPEG
++if TIFF_TOOLS
+ JPEG_DEPENDENT_CHECK_PROG=raw_decode
+ JPEG_DEPENDENT_TESTSCRIPTS=\
+ 	tiff2rgba-quad-tile.jpg.sh \
+ 	tiff2rgba-ojpeg_zackthecat_subsamp22_single_strip.sh \
+ 	tiff2rgba-ojpeg_chewey_subsamp21_multi_strip.sh \
+ 	tiff2rgba-ojpeg_single_strip_no_rowsperstrip.sh
+-
++endif
+ else
+ JPEG_DEPENDENT_CHECK_PROG=
+ JPEG_DEPENDENT_TESTSCRIPTS=
+@@ -76,6 +77,7 @@ check_PROGRAMS = \
+ endif
+ 
+ # Test scripts to execute
++if TIFF_TOOLS
+ TESTSCRIPTS = \
+ 	ppm2tiff_pbm.sh \
+ 	ppm2tiff_pgm.sh \
+@@ -156,6 +158,9 @@ TESTSCRIPTS = \
+ 	testfax4.sh \
+ 	testdeflatelaststripextradata.sh \
+ 	$(JPEG_DEPENDENT_TESTSCRIPTS)
++else
++TESTSCRIPTS=
++endif
+ 
+ # This list should contain the references files
+ # from the 'refs' subdirectory
+-- 
+GitLab

diff --git a/media-libs/tiff/tiff-4.5.0_rc1.ebuild b/media-libs/tiff/tiff-4.5.0_rc1.ebuild
new file mode 100644
index 000000000000..fd1df52b1205
--- /dev/null
+++ b/media-libs/tiff/tiff-4.5.0_rc1.ebuild
@@ -0,0 +1,89 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+QA_PKGCONFIG_VERSION="$(ver_cut 1-3)"
+
+# Release signer can vary per version but not clear if others will be doing
+# them in future, so gone with Even Rouault for now as he does other geosci
+# stuff too like PROJ, GDAL. Previous release manager of TIFF was
+# GraphicsMagick maintainer Bob Friesenhahn. Please be careful when verifying
+# who made releases.
+VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/rouault.asc
+inherit autotools multilib-minimal verify-sig libtool flag-o-matic
+
+MY_P="${P/_rc/rc}"
+DESCRIPTION="Tag Image File Format (TIFF) library"
+HOMEPAGE="http://libtiff.maptools.org"
+SRC_URI="https://download.osgeo.org/libtiff/${MY_P}.tar.xz"
+SRC_URI+=" verify-sig? ( https://download.osgeo.org/libtiff/${MY_P}.tar.xz.sig )"
+S="${WORKDIR}/${PN}-$(ver_cut 1-3)"
+
+LICENSE="libtiff"
+SLOT="0/6"
+if [[ ${PV} != *_rc* ]] ; then
+	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+fi
+IUSE="+cxx jbig jpeg lzma static-libs test webp zlib zstd"
+RESTRICT="!test? ( test )"
+
+# bug #483132
+REQUIRED_USE="test? ( jpeg )"
+
+RDEPEND="jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
+	jpeg? ( media-libs/libjpeg-turbo:=[${MULTILIB_USEDEP}] )
+	lzma? ( >=app-arch/xz-utils-5.0.5-r1[${MULTILIB_USEDEP}] )
+	webp? ( media-libs/libwebp:=[${MULTILIB_USEDEP}] )
+	zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )
+	zstd? ( >=app-arch/zstd-1.3.7-r1:=[${MULTILIB_USEDEP}] )"
+DEPEND="${RDEPEND}"
+BDEPEND="verify-sig? ( sec-keys/openpgp-keys-evenrouault )"
+
+MULTILIB_WRAPPED_HEADERS=(
+	/usr/include/tiffconf.h
+)
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-4.5.0_rc1-skip-tools-tests-multilib.patch
+)
+
+src_prepare() {
+	default
+
+	# Added to fix cross-compilation
+	#elibtoolize
+
+	# For skip-tools-tests-multilib.patch
+	eautoreconf
+}
+
+multilib_src_configure() {
+	append-lfs-flags
+
+	local myeconfargs=(
+		--disable-sphinx
+		--without-x
+		--with-docdir="${EPREFIX}"/usr/share/doc/${PF}
+		$(use_enable cxx)
+		$(use_enable jbig)
+		$(use_enable jpeg)
+		$(use_enable lzma)
+		$(use_enable static-libs static)
+		$(use_enable test tests)
+		$(use_enable webp)
+		$(use_enable zlib)
+		$(use_enable zstd)
+
+		$(multilib_native_enable docs)
+		$(multilib_native_enable contrib)
+		$(multilib_native_enable tools)
+	)
+
+	ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+}
+
+multilib_src_install_all() {
+	find "${ED}" -type f -name '*.la' -delete || die
+	rm "${ED}"/usr/share/doc/${PF}/{README*,RELEASE-DATE,TODO,VERSION} || die
+}


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/
@ 2023-02-22 16:21 Sam James
  0 siblings, 0 replies; 13+ messages in thread
From: Sam James @ 2023-02-22 16:21 UTC (permalink / raw
  To: gentoo-commits

commit:     7ebadfbb4602052047e063e83e78cf398d2610c5
Author:     Michael Vetter <jubalh <AT> iodoru <DOT> org>
AuthorDate: Wed Feb 22 15:28:54 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Feb 22 16:21:38 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7ebadfbb

media-libs/tiff: Fix several CVEs

Fixes:
* CVE-2023-0795 https://gitlab.com/libtiff/libtiff/-/issues/493
* CVE-2023-0796 https://gitlab.com/libtiff/libtiff/-/issues/499
* CVE-2023-0797 https://gitlab.com/libtiff/libtiff/-/issues/495
* CVE-2023-0798 https://gitlab.com/libtiff/libtiff/-/issues/492
* CVE-2023-0799 https://gitlab.com/libtiff/libtiff/-/issues/494
* CVE-2023-0800 https://gitlab.com/libtiff/libtiff/-/issues/496
* CVE-2023-0801 https://gitlab.com/libtiff/libtiff/-/issues/498
* CVE-2023-0802 https://gitlab.com/libtiff/libtiff/-/issues/500
* CVE-2023-0803 https://gitlab.com/libtiff/libtiff/-/issues/501
* CVE-2023-0804 https://gitlab.com/libtiff/libtiff/-/issues/497

Bug: https://github.com/gentoo/gentoo/pull/29721
Signed-off-by: Michael Vetter <jubalh <AT> iodoru.org>
Closes: https://github.com/gentoo/gentoo/pull/29721
Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...CVE-2023-0797-CVE-2023-0798-CVE-2023-0799.patch | 287 +++++++++++++++++++++
 ...CVE-2023-0802-CVE-2023-0803-CVE-2023-0804.patch | 131 ++++++++++
 media-libs/tiff/tiff-4.5.0-r2.ebuild               |  92 +++++++
 3 files changed, 510 insertions(+)

diff --git a/media-libs/tiff/files/tiff-4.5.0-CVE-2023-0795-CVE-2023-0796-CVE-2023-0797-CVE-2023-0798-CVE-2023-0799.patch b/media-libs/tiff/files/tiff-4.5.0-CVE-2023-0795-CVE-2023-0796-CVE-2023-0797-CVE-2023-0798-CVE-2023-0799.patch
new file mode 100644
index 000000000000..70a9b8269ec5
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.5.0-CVE-2023-0795-CVE-2023-0796-CVE-2023-0797-CVE-2023-0798-CVE-2023-0799.patch
@@ -0,0 +1,287 @@
+Index: tiff-4.5.0/tools/tiffcrop.c
+===================================================================
+Upstream commits:
+https://gitlab.com/libtiff/libtiff/-/commit/afaabc3e50d4e5d80a94143f7e3c997e7e410f68
+https://gitlab.com/libtiff/libtiff/-/commit/9c22495e5eeeae9e00a1596720c969656bb8d678
+From 9c22495e5eeeae9e00a1596720c969656bb8d678 Mon Sep 17 00:00:00 2001
+From: Su_Laus <sulau@freenet.de>
+Date: Fri, 3 Feb 2023 15:31:31 +0100
+Subject: [PATCH] tiffcrop correctly update buffersize after rotateImage()
+ fix#520 rotateImage() set up a new buffer and calculates its size
+ individually. Therefore, seg_buffs[] size needs to be updated accordingly.
+ Before this fix, the seg_buffs buffer size was calculated with a different
+ formula than within rotateImage().
+
+Closes #520.
+---
+ tools/tiffcrop.c | 36 ++++++++++++++++++++----------------
+ 1 file changed, 20 insertions(+), 16 deletions(-)
+
+diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
+index 7db69883..f8b66188 100644
+--- a/tools/tiffcrop.c
++++ b/tools/tiffcrop.c
+@@ -577,7 +577,7 @@ static int rotateContigSamples24bits(uint16_t, uint16_t, uint16_t, uint32_t,
+ static int rotateContigSamples32bits(uint16_t, uint16_t, uint16_t, uint32_t,
+                                      uint32_t, uint32_t, uint8_t *, uint8_t *);
+ static int rotateImage(uint16_t, struct image_data *, uint32_t *, uint32_t *,
+-                       unsigned char **);
++                       unsigned char **, size_t *);
+ static int mirrorImage(uint16_t, uint16_t, uint16_t, uint32_t, uint32_t,
+                        unsigned char *);
+ static int invertImage(uint16_t, uint16_t, uint16_t, uint32_t, uint32_t,
+@@ -7243,7 +7243,7 @@ static int correct_orientation(struct image_data *image,
+         }
+ 
+         if (rotateImage(rotation, image, &image->width, &image->length,
+-                        work_buff_ptr))
++                        work_buff_ptr, NULL))
+         {
+             TIFFError("correct_orientation", "Unable to rotate image");
+             return (-1);
+@@ -8563,8 +8563,12 @@ static int processCropSelections(struct image_data *image,
+         if (crop->crop_mode & CROP_ROTATE) /* rotate should be last as it can
+                                               reallocate the buffer */
+         {
++            /* rotateImage() set up a new buffer and calculates its size
++             * individually. Therefore, seg_buffs size  needs to be updated
++             * accordingly. */
++            size_t rot_buf_size = 0;
+             if (rotateImage(crop->rotation, image, &crop->combined_width,
+-                            &crop->combined_length, &crop_buff))
++                            &crop->combined_length, &crop_buff, &rot_buf_size))
+             {
+                 TIFFError("processCropSelections",
+                           "Failed to rotate composite regions by %" PRIu32
+@@ -8573,9 +8577,7 @@ static int processCropSelections(struct image_data *image,
+                 return (-1);
+             }
+             seg_buffs[0].buffer = crop_buff;
+-            seg_buffs[0].size =
+-                (((crop->combined_width * image->bps + 7) / 8) * image->spp) *
+-                crop->combined_length;
++            seg_buffs[0].size = rot_buf_size;
+         }
+     }
+     else /* Separated Images */
+@@ -8686,10 +8688,13 @@ static int processCropSelections(struct image_data *image,
+                  * ->yres, what it schouldn't do here, when more than one
+                  * section is processed. ToDo: Therefore rotateImage() and its
+                  * usage has to be reworked (e.g. like mirrorImage()) !!
+-                 */
+-                if (rotateImage(crop->rotation, image,
+-                                &crop->regionlist[i].width,
+-                                &crop->regionlist[i].length, &crop_buff))
++                 * Furthermore, rotateImage() set up a new buffer and calculates
++                 * its size individually. Therefore, seg_buffs size  needs to be
++                 * updated accordingly. */
++                size_t rot_buf_size = 0;
++                if (rotateImage(
++                        crop->rotation, image, &crop->regionlist[i].width,
++                        &crop->regionlist[i].length, &crop_buff, &rot_buf_size))
+                 {
+                     TIFFError("processCropSelections",
+                               "Failed to rotate crop region by %" PRIu16
+@@ -8702,10 +8707,7 @@ static int processCropSelections(struct image_data *image,
+                 crop->combined_width = total_width;
+                 crop->combined_length = total_length;
+                 seg_buffs[i].buffer = crop_buff;
+-                seg_buffs[i].size =
+-                    (((crop->regionlist[i].width * image->bps + 7) / 8) *
+-                     image->spp) *
+-                    crop->regionlist[i].length;
++                seg_buffs[i].size = rot_buf_size;
+             }
+         } /* for crop->selections loop */
+     }     /* Separated Images (else case) */
+@@ -8836,7 +8838,7 @@ static int createCroppedImage(struct image_data *image, struct crop_mask *crop,
+         CROP_ROTATE) /* rotate should be last as it can reallocate the buffer */
+     {
+         if (rotateImage(crop->rotation, image, &crop->combined_width,
+-                        &crop->combined_length, crop_buff_ptr))
++                        &crop->combined_length, crop_buff_ptr, NULL))
+         {
+             TIFFError("createCroppedImage",
+                       "Failed to rotate image or cropped selection by %" PRIu16
+@@ -9552,7 +9554,7 @@ static int rotateContigSamples32bits(uint16_t rotation, uint16_t spp,
+ /* Rotate an image by a multiple of 90 degrees clockwise */
+ static int rotateImage(uint16_t rotation, struct image_data *image,
+                        uint32_t *img_width, uint32_t *img_length,
+-                       unsigned char **ibuff_ptr)
++                       unsigned char **ibuff_ptr, size_t *rot_buf_size)
+ {
+     int shift_width;
+     uint32_t bytes_per_pixel, bytes_per_sample;
+@@ -9610,6 +9612,8 @@ static int rotateImage(uint16_t rotation, struct image_data *image,
+         return (-1);
+     }
+     _TIFFmemset(rbuff, '\0', buffsize + NUM_BUFF_OVERSIZE_BYTES);
++    if (rot_buf_size != NULL)
++        *rot_buf_size = buffsize;
+ 
+     ibuff = *ibuff_ptr;
+     switch (rotation)
+-- 
+GitLab
+
+From 69818e2f2d246e6631ac2a2da692c3706b849c38 Mon Sep 17 00:00:00 2001
+From: Su_Laus <sulau@freenet.de>
+Date: Sun, 29 Jan 2023 11:09:26 +0100
+Subject: [PATCH] tiffcrop: Amend rotateImage() not to toggle the input (main)
+ image width and length parameters when only cropped image sections are
+ rotated. Remove buffptr from region structure because never used.
+
+Closes #492 #493 #494 #495 #499 #518 #519
+---
+ tools/tiffcrop.c | 59 ++++++++++++++++++++++++++++--------------------
+ 1 file changed, 35 insertions(+), 24 deletions(-)
+
+diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
+index ebea7475..519871ec 100644
+--- a/tools/tiffcrop.c
++++ b/tools/tiffcrop.c
+@@ -296,7 +296,6 @@ struct region
+     uint32_t width;    /* width in pixels */
+     uint32_t length;   /* length in pixels */
+     uint32_t buffsize; /* size of buffer needed to hold the cropped region */
+-    unsigned char *buffptr; /* address of start of the region */
+ };
+ 
+ /* Cropping parameters from command line and image data
+@@ -577,7 +576,7 @@ static int rotateContigSamples24bits(uint16_t, uint16_t, uint16_t, uint32_t,
+ static int rotateContigSamples32bits(uint16_t, uint16_t, uint16_t, uint32_t,
+                                      uint32_t, uint32_t, uint8_t *, uint8_t *);
+ static int rotateImage(uint16_t, struct image_data *, uint32_t *, uint32_t *,
+-                       unsigned char **, size_t *);
++                       unsigned char **, size_t *, int);
+ static int mirrorImage(uint16_t, uint16_t, uint16_t, uint32_t, uint32_t,
+                        unsigned char *);
+ static int invertImage(uint16_t, uint16_t, uint16_t, uint32_t, uint32_t,
+@@ -5782,7 +5781,6 @@ static void initCropMasks(struct crop_mask *cps)
+         cps->regionlist[i].width = 0;
+         cps->regionlist[i].length = 0;
+         cps->regionlist[i].buffsize = 0;
+-        cps->regionlist[i].buffptr = NULL;
+         cps->zonelist[i].position = 0;
+         cps->zonelist[i].total = 0;
+     }
+@@ -7266,9 +7264,13 @@ static int correct_orientation(struct image_data *image,
+                       (uint16_t)(image->adjustments & ROTATE_ANY));
+             return (-1);
+         }
+-
+-        if (rotateImage(rotation, image, &image->width, &image->length,
+-                        work_buff_ptr, NULL))
++        /* Dummy variable in order not to switch two times the
++         * image->width,->length within rotateImage(),
++         * but switch xres, yres there. */
++        uint32_t width = image->width;
++        uint32_t length = image->length;
++        if (rotateImage(rotation, image, &width, &length, work_buff_ptr, NULL,
++                        TRUE))
+         {
+             TIFFError("correct_orientation", "Unable to rotate image");
+             return (-1);
+@@ -7377,7 +7379,6 @@ static int extractCompositeRegions(struct image_data *image,
+         /* These should not be needed for composite images */
+         crop->regionlist[i].width = crop_width;
+         crop->regionlist[i].length = crop_length;
+-        crop->regionlist[i].buffptr = crop_buff;
+ 
+         src_rowsize = ((img_width * bps * spp) + 7) / 8;
+         dst_rowsize = (((crop_width * bps * count) + 7) / 8);
+@@ -7640,7 +7641,6 @@ static int extractSeparateRegion(struct image_data *image,
+ 
+     crop->regionlist[region].width = crop_width;
+     crop->regionlist[region].length = crop_length;
+-    crop->regionlist[region].buffptr = crop_buff;
+ 
+     src = read_buff;
+     dst = crop_buff;
+@@ -8635,7 +8635,8 @@ static int processCropSelections(struct image_data *image,
+              * accordingly. */
+             size_t rot_buf_size = 0;
+             if (rotateImage(crop->rotation, image, &crop->combined_width,
+-                            &crop->combined_length, &crop_buff, &rot_buf_size))
++                            &crop->combined_length, &crop_buff, &rot_buf_size,
++                            FALSE))
+             {
+                 TIFFError("processCropSelections",
+                           "Failed to rotate composite regions by %" PRIu32
+@@ -8759,9 +8760,10 @@ static int processCropSelections(struct image_data *image,
+                  * its size individually. Therefore, seg_buffs size  needs to be
+                  * updated accordingly. */
+                 size_t rot_buf_size = 0;
+-                if (rotateImage(
+-                        crop->rotation, image, &crop->regionlist[i].width,
+-                        &crop->regionlist[i].length, &crop_buff, &rot_buf_size))
++                if (rotateImage(crop->rotation, image,
++                                &crop->regionlist[i].width,
++                                &crop->regionlist[i].length, &crop_buff,
++                                &rot_buf_size, FALSE))
+                 {
+                     TIFFError("processCropSelections",
+                               "Failed to rotate crop region by %" PRIu16
+@@ -8905,7 +8907,7 @@ static int createCroppedImage(struct image_data *image, struct crop_mask *crop,
+         CROP_ROTATE) /* rotate should be last as it can reallocate the buffer */
+     {
+         if (rotateImage(crop->rotation, image, &crop->combined_width,
+-                        &crop->combined_length, crop_buff_ptr, NULL))
++                        &crop->combined_length, crop_buff_ptr, NULL, TRUE))
+         {
+             TIFFError("createCroppedImage",
+                       "Failed to rotate image or cropped selection by %" PRIu16
+@@ -9621,7 +9623,8 @@ static int rotateContigSamples32bits(uint16_t rotation, uint16_t spp,
+ /* Rotate an image by a multiple of 90 degrees clockwise */
+ static int rotateImage(uint16_t rotation, struct image_data *image,
+                        uint32_t *img_width, uint32_t *img_length,
+-                       unsigned char **ibuff_ptr, size_t *rot_buf_size)
++                       unsigned char **ibuff_ptr, size_t *rot_buf_size,
++                       int rot_image_params)
+ {
+     int shift_width;
+     uint32_t bytes_per_pixel, bytes_per_sample;
+@@ -9869,11 +9872,15 @@ static int rotateImage(uint16_t rotation, struct image_data *image,
+ 
+             *img_width = length;
+             *img_length = width;
+-            image->width = length;
+-            image->length = width;
+-            res_temp = image->xres;
+-            image->xres = image->yres;
+-            image->yres = res_temp;
++            /* Only toggle image parameters if whole input image is rotated. */
++            if (rot_image_params)
++            {
++                image->width = length;
++                image->length = width;
++                res_temp = image->xres;
++                image->xres = image->yres;
++                image->yres = res_temp;
++            }
+             break;
+ 
+         case 270:
+@@ -9956,11 +9963,15 @@ static int rotateImage(uint16_t rotation, struct image_data *image,
+ 
+             *img_width = length;
+             *img_length = width;
+-            image->width = length;
+-            image->length = width;
+-            res_temp = image->xres;
+-            image->xres = image->yres;
+-            image->yres = res_temp;
++            /* Only toggle image parameters if whole input image is rotated. */
++            if (rot_image_params)
++            {
++                image->width = length;
++                image->length = width;
++                res_temp = image->xres;
++                image->xres = image->yres;
++                image->yres = res_temp;
++            }
+             break;
+         default:
+             break;
+-- 
+GitLab

diff --git a/media-libs/tiff/files/tiff-4.5.0-CVE-2023-0800-CVE-2023-0801-CVE-2023-0802-CVE-2023-0803-CVE-2023-0804.patch b/media-libs/tiff/files/tiff-4.5.0-CVE-2023-0800-CVE-2023-0801-CVE-2023-0802-CVE-2023-0803-CVE-2023-0804.patch
new file mode 100644
index 000000000000..41fe439f9159
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.5.0-CVE-2023-0800-CVE-2023-0801-CVE-2023-0802-CVE-2023-0803-CVE-2023-0804.patch
@@ -0,0 +1,131 @@
+Index: tiff-4.5.0/tools/tiffcrop.c
+===================================================================
+Upstream commit:
+https://gitlab.com/libtiff/libtiff/-/commit/33aee1275d9d1384791d2206776eb8152d397f00
+From 82a7fbb1fa7228499ffeb3a57a1d106a9626d57c Mon Sep 17 00:00:00 2001
+From: Su Laus <sulau@freenet.de>
+Date: Sun, 5 Feb 2023 15:53:15 +0000
+Subject: [PATCH] tiffcrop: added check for assumption on composite images
+ (fixes #496)
+
+tiffcrop: For composite images with more than one region, the combined_length or combined_width always needs to be equal, respectively. Otherwise, even the first section/region copy action might cause buffer overrun. This is now checked before the first copy action.
+
+Closes #496, #497, #498, #500, #501.
+---
+ tools/tiffcrop.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 66 insertions(+), 2 deletions(-)
+
+diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
+index 84e26ac6..480b927c 100644
+--- a/tools/tiffcrop.c
++++ b/tools/tiffcrop.c
+@@ -5935,18 +5935,40 @@ static int computeInputPixelOffsets(struct crop_mask *crop,
+ 
+             crop->regionlist[i].buffsize = buffsize;
+             crop->bufftotal += buffsize;
++
++            /* For composite images with more than one region, the
++             * combined_length or combined_width always needs to be equal,
++             * respectively.
++             * Otherwise, even the first section/region copy
++             * action might cause buffer overrun. */
+             if (crop->img_mode == COMPOSITE_IMAGES)
+             {
+                 switch (crop->edge_ref)
+                 {
+                     case EDGE_LEFT:
+                     case EDGE_RIGHT:
++                        if (i > 0 && zlength != crop->combined_length)
++                        {
++                            TIFFError(
++                                "computeInputPixelOffsets",
++                                "Only equal length regions can be combined for "
++                                "-E left or right");
++                            return (-1);
++                        }
+                         crop->combined_length = zlength;
+                         crop->combined_width += zwidth;
+                         break;
+                     case EDGE_BOTTOM:
+                     case EDGE_TOP: /* width from left, length from top */
+                     default:
++                        if (i > 0 && zwidth != crop->combined_width)
++                        {
++                            TIFFError("computeInputPixelOffsets",
++                                      "Only equal width regions can be "
++                                      "combined for -E "
++                                      "top or bottom");
++                            return (-1);
++                        }
+                         crop->combined_width = zwidth;
+                         crop->combined_length += zlength;
+                         break;
+@@ -7301,6 +7323,46 @@ static int extractCompositeRegions(struct image_data *image,
+     crop->combined_width = 0;
+     crop->combined_length = 0;
+ 
++    /* If there is more than one region, check beforehand whether all the width
++     * and length values of the regions are the same, respectively. */
++    switch (crop->edge_ref)
++    {
++        default:
++        case EDGE_TOP:
++        case EDGE_BOTTOM:
++            for (i = 1; i < crop->selections; i++)
++            {
++                uint32_t crop_width0 =
++                    crop->regionlist[i - 1].x2 - crop->regionlist[i - 1].x1 + 1;
++                uint32_t crop_width1 =
++                    crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1;
++                if (crop_width0 != crop_width1)
++                {
++                    TIFFError("extractCompositeRegions",
++                              "Only equal width regions can be combined for -E "
++                              "top or bottom");
++                    return (1);
++                }
++            }
++            break;
++        case EDGE_LEFT:
++        case EDGE_RIGHT:
++            for (i = 1; i < crop->selections; i++)
++            {
++                uint32_t crop_length0 =
++                    crop->regionlist[i - 1].y2 - crop->regionlist[i - 1].y1 + 1;
++                uint32_t crop_length1 =
++                    crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1;
++                if (crop_length0 != crop_length1)
++                {
++                    TIFFError("extractCompositeRegions",
++                              "Only equal length regions can be combined for "
++                              "-E left or right");
++                    return (1);
++                }
++            }
++    }
++
+     for (i = 0; i < crop->selections; i++)
+     {
+         /* rows, columns, width, length are expressed in pixels */
+@@ -7325,7 +7387,8 @@ static int extractCompositeRegions(struct image_data *image,
+             default:
+             case EDGE_TOP:
+             case EDGE_BOTTOM:
+-                if ((i > 0) && (crop_width != crop->regionlist[i - 1].width))
++                if ((crop->selections > i + 1) &&
++                    (crop_width != crop->regionlist[i + 1].width))
+                 {
+                     TIFFError("extractCompositeRegions",
+                               "Only equal width regions can be combined for -E "
+@@ -7418,7 +7481,8 @@ static int extractCompositeRegions(struct image_data *image,
+             case EDGE_LEFT: /* splice the pieces of each row together, side by
+                                side */
+             case EDGE_RIGHT:
+-                if ((i > 0) && (crop_length != crop->regionlist[i - 1].length))
++                if ((crop->selections > i + 1) &&
++                    (crop_length != crop->regionlist[i + 1].length))
+                 {
+                     TIFFError("extractCompositeRegions",
+                               "Only equal length regions can be combined for "
+-- 
+GitLab

diff --git a/media-libs/tiff/tiff-4.5.0-r2.ebuild b/media-libs/tiff/tiff-4.5.0-r2.ebuild
new file mode 100644
index 000000000000..00f6bb711511
--- /dev/null
+++ b/media-libs/tiff/tiff-4.5.0-r2.ebuild
@@ -0,0 +1,92 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+QA_PKGCONFIG_VERSION="$(ver_cut 1-3)"
+
+# Release signer can vary per version but not clear if others will be doing
+# them in future, so gone with Even Rouault for now as he does other geosci
+# stuff too like PROJ, GDAL. Previous release manager of TIFF was
+# GraphicsMagick maintainer Bob Friesenhahn. Please be careful when verifying
+# who made releases.
+VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/rouault.asc
+inherit autotools multilib-minimal verify-sig flag-o-matic
+
+MY_P="${P/_rc/rc}"
+DESCRIPTION="Tag Image File Format (TIFF) library"
+HOMEPAGE="http://libtiff.maptools.org"
+SRC_URI="https://download.osgeo.org/libtiff/${MY_P}.tar.xz"
+SRC_URI+=" verify-sig? ( https://download.osgeo.org/libtiff/${MY_P}.tar.xz.sig )"
+S="${WORKDIR}/${PN}-$(ver_cut 1-3)"
+
+LICENSE="libtiff"
+SLOT="0/6"
+if [[ ${PV} != *_rc* ]] ; then
+	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+fi
+IUSE="+cxx jbig jpeg lzma static-libs test webp zlib zstd"
+RESTRICT="!test? ( test )"
+
+# bug #483132
+REQUIRED_USE="test? ( jpeg )"
+
+RDEPEND="jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
+	jpeg? ( media-libs/libjpeg-turbo:=[${MULTILIB_USEDEP}] )
+	lzma? ( >=app-arch/xz-utils-5.0.5-r1[${MULTILIB_USEDEP}] )
+	webp? ( media-libs/libwebp:=[${MULTILIB_USEDEP}] )
+	zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )
+	zstd? ( >=app-arch/zstd-1.3.7-r1:=[${MULTILIB_USEDEP}] )"
+DEPEND="${RDEPEND}"
+BDEPEND="verify-sig? ( sec-keys/openpgp-keys-evenrouault )"
+
+MULTILIB_WRAPPED_HEADERS=(
+	/usr/include/tiffconf.h
+)
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-4.5.0_rc1-skip-tools-tests-multilib.patch
+	"${FILESDIR}"/${PN}-4.5.0-CVE-2022-48281.patch
+	"${FILESDIR}"/${PN}-4.5.0-CVE-2023-0795-CVE-2023-0796-CVE-2023-0797-CVE-2023-0798-CVE-2023-0799.patch
+	"${FILESDIR}"/${PN}-4.5.0-CVE-2023-0800-CVE-2023-0801-CVE-2023-0802-CVE-2023-0803-CVE-2023-0804.patch
+)
+
+src_prepare() {
+	default
+
+	# Added to fix cross-compilation
+	#elibtoolize
+
+	# For skip-tools-tests-multilib.patch
+	eautoreconf
+}
+
+multilib_src_configure() {
+	append-lfs-flags
+
+	local myeconfargs=(
+		--disable-sphinx
+		--without-x
+		--with-docdir="${EPREFIX}"/usr/share/doc/${PF}
+		$(use_enable cxx)
+		$(use_enable jbig)
+		$(use_enable jpeg)
+		$(use_enable lzma)
+		$(use_enable static-libs static)
+		$(use_enable test tests)
+		$(use_enable webp)
+		$(use_enable zlib)
+		$(use_enable zstd)
+
+		$(multilib_native_enable docs)
+		$(multilib_native_enable contrib)
+		$(multilib_native_enable tools)
+	)
+
+	ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+}
+
+multilib_src_install_all() {
+	find "${ED}" -type f -name '*.la' -delete || die
+	rm "${ED}"/usr/share/doc/${PF}/{README*,RELEASE-DATE,TODO,VERSION} || die
+}


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/
@ 2023-02-22 16:23 Sam James
  0 siblings, 0 replies; 13+ messages in thread
From: Sam James @ 2023-02-22 16:23 UTC (permalink / raw
  To: gentoo-commits

commit:     53cfbff2eb33daf68de4a26712be94e2a7fa7c10
Author:     Michael Vetter <jubalh <AT> iodoru <DOT> org>
AuthorDate: Wed Feb 22 15:28:54 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Feb 22 16:23:17 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=53cfbff2

media-libs/tiff: Fix several CVEs

Fixes:
* CVE-2023-0795 https://gitlab.com/libtiff/libtiff/-/issues/493
* CVE-2023-0796 https://gitlab.com/libtiff/libtiff/-/issues/499
* CVE-2023-0797 https://gitlab.com/libtiff/libtiff/-/issues/495
* CVE-2023-0798 https://gitlab.com/libtiff/libtiff/-/issues/492
* CVE-2023-0799 https://gitlab.com/libtiff/libtiff/-/issues/494
* CVE-2023-0800 https://gitlab.com/libtiff/libtiff/-/issues/496
* CVE-2023-0801 https://gitlab.com/libtiff/libtiff/-/issues/498
* CVE-2023-0802 https://gitlab.com/libtiff/libtiff/-/issues/500
* CVE-2023-0803 https://gitlab.com/libtiff/libtiff/-/issues/501
* CVE-2023-0804 https://gitlab.com/libtiff/libtiff/-/issues/497

Bug: https://bugs.gentoo.org/895900
Signed-off-by: Michael Vetter <jubalh <AT> iodoru.org>
Closes: https://github.com/gentoo/gentoo/pull/29721
Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...CVE-2023-0797-CVE-2023-0798-CVE-2023-0799.patch | 287 +++++++++++++++++++++
 ...CVE-2023-0802-CVE-2023-0803-CVE-2023-0804.patch | 131 ++++++++++
 media-libs/tiff/tiff-4.5.0-r2.ebuild               |  92 +++++++
 3 files changed, 510 insertions(+)

diff --git a/media-libs/tiff/files/tiff-4.5.0-CVE-2023-0795-CVE-2023-0796-CVE-2023-0797-CVE-2023-0798-CVE-2023-0799.patch b/media-libs/tiff/files/tiff-4.5.0-CVE-2023-0795-CVE-2023-0796-CVE-2023-0797-CVE-2023-0798-CVE-2023-0799.patch
new file mode 100644
index 000000000000..70a9b8269ec5
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.5.0-CVE-2023-0795-CVE-2023-0796-CVE-2023-0797-CVE-2023-0798-CVE-2023-0799.patch
@@ -0,0 +1,287 @@
+Index: tiff-4.5.0/tools/tiffcrop.c
+===================================================================
+Upstream commits:
+https://gitlab.com/libtiff/libtiff/-/commit/afaabc3e50d4e5d80a94143f7e3c997e7e410f68
+https://gitlab.com/libtiff/libtiff/-/commit/9c22495e5eeeae9e00a1596720c969656bb8d678
+From 9c22495e5eeeae9e00a1596720c969656bb8d678 Mon Sep 17 00:00:00 2001
+From: Su_Laus <sulau@freenet.de>
+Date: Fri, 3 Feb 2023 15:31:31 +0100
+Subject: [PATCH] tiffcrop correctly update buffersize after rotateImage()
+ fix#520 rotateImage() set up a new buffer and calculates its size
+ individually. Therefore, seg_buffs[] size needs to be updated accordingly.
+ Before this fix, the seg_buffs buffer size was calculated with a different
+ formula than within rotateImage().
+
+Closes #520.
+---
+ tools/tiffcrop.c | 36 ++++++++++++++++++++----------------
+ 1 file changed, 20 insertions(+), 16 deletions(-)
+
+diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
+index 7db69883..f8b66188 100644
+--- a/tools/tiffcrop.c
++++ b/tools/tiffcrop.c
+@@ -577,7 +577,7 @@ static int rotateContigSamples24bits(uint16_t, uint16_t, uint16_t, uint32_t,
+ static int rotateContigSamples32bits(uint16_t, uint16_t, uint16_t, uint32_t,
+                                      uint32_t, uint32_t, uint8_t *, uint8_t *);
+ static int rotateImage(uint16_t, struct image_data *, uint32_t *, uint32_t *,
+-                       unsigned char **);
++                       unsigned char **, size_t *);
+ static int mirrorImage(uint16_t, uint16_t, uint16_t, uint32_t, uint32_t,
+                        unsigned char *);
+ static int invertImage(uint16_t, uint16_t, uint16_t, uint32_t, uint32_t,
+@@ -7243,7 +7243,7 @@ static int correct_orientation(struct image_data *image,
+         }
+ 
+         if (rotateImage(rotation, image, &image->width, &image->length,
+-                        work_buff_ptr))
++                        work_buff_ptr, NULL))
+         {
+             TIFFError("correct_orientation", "Unable to rotate image");
+             return (-1);
+@@ -8563,8 +8563,12 @@ static int processCropSelections(struct image_data *image,
+         if (crop->crop_mode & CROP_ROTATE) /* rotate should be last as it can
+                                               reallocate the buffer */
+         {
++            /* rotateImage() set up a new buffer and calculates its size
++             * individually. Therefore, seg_buffs size  needs to be updated
++             * accordingly. */
++            size_t rot_buf_size = 0;
+             if (rotateImage(crop->rotation, image, &crop->combined_width,
+-                            &crop->combined_length, &crop_buff))
++                            &crop->combined_length, &crop_buff, &rot_buf_size))
+             {
+                 TIFFError("processCropSelections",
+                           "Failed to rotate composite regions by %" PRIu32
+@@ -8573,9 +8577,7 @@ static int processCropSelections(struct image_data *image,
+                 return (-1);
+             }
+             seg_buffs[0].buffer = crop_buff;
+-            seg_buffs[0].size =
+-                (((crop->combined_width * image->bps + 7) / 8) * image->spp) *
+-                crop->combined_length;
++            seg_buffs[0].size = rot_buf_size;
+         }
+     }
+     else /* Separated Images */
+@@ -8686,10 +8688,13 @@ static int processCropSelections(struct image_data *image,
+                  * ->yres, what it schouldn't do here, when more than one
+                  * section is processed. ToDo: Therefore rotateImage() and its
+                  * usage has to be reworked (e.g. like mirrorImage()) !!
+-                 */
+-                if (rotateImage(crop->rotation, image,
+-                                &crop->regionlist[i].width,
+-                                &crop->regionlist[i].length, &crop_buff))
++                 * Furthermore, rotateImage() set up a new buffer and calculates
++                 * its size individually. Therefore, seg_buffs size  needs to be
++                 * updated accordingly. */
++                size_t rot_buf_size = 0;
++                if (rotateImage(
++                        crop->rotation, image, &crop->regionlist[i].width,
++                        &crop->regionlist[i].length, &crop_buff, &rot_buf_size))
+                 {
+                     TIFFError("processCropSelections",
+                               "Failed to rotate crop region by %" PRIu16
+@@ -8702,10 +8707,7 @@ static int processCropSelections(struct image_data *image,
+                 crop->combined_width = total_width;
+                 crop->combined_length = total_length;
+                 seg_buffs[i].buffer = crop_buff;
+-                seg_buffs[i].size =
+-                    (((crop->regionlist[i].width * image->bps + 7) / 8) *
+-                     image->spp) *
+-                    crop->regionlist[i].length;
++                seg_buffs[i].size = rot_buf_size;
+             }
+         } /* for crop->selections loop */
+     }     /* Separated Images (else case) */
+@@ -8836,7 +8838,7 @@ static int createCroppedImage(struct image_data *image, struct crop_mask *crop,
+         CROP_ROTATE) /* rotate should be last as it can reallocate the buffer */
+     {
+         if (rotateImage(crop->rotation, image, &crop->combined_width,
+-                        &crop->combined_length, crop_buff_ptr))
++                        &crop->combined_length, crop_buff_ptr, NULL))
+         {
+             TIFFError("createCroppedImage",
+                       "Failed to rotate image or cropped selection by %" PRIu16
+@@ -9552,7 +9554,7 @@ static int rotateContigSamples32bits(uint16_t rotation, uint16_t spp,
+ /* Rotate an image by a multiple of 90 degrees clockwise */
+ static int rotateImage(uint16_t rotation, struct image_data *image,
+                        uint32_t *img_width, uint32_t *img_length,
+-                       unsigned char **ibuff_ptr)
++                       unsigned char **ibuff_ptr, size_t *rot_buf_size)
+ {
+     int shift_width;
+     uint32_t bytes_per_pixel, bytes_per_sample;
+@@ -9610,6 +9612,8 @@ static int rotateImage(uint16_t rotation, struct image_data *image,
+         return (-1);
+     }
+     _TIFFmemset(rbuff, '\0', buffsize + NUM_BUFF_OVERSIZE_BYTES);
++    if (rot_buf_size != NULL)
++        *rot_buf_size = buffsize;
+ 
+     ibuff = *ibuff_ptr;
+     switch (rotation)
+-- 
+GitLab
+
+From 69818e2f2d246e6631ac2a2da692c3706b849c38 Mon Sep 17 00:00:00 2001
+From: Su_Laus <sulau@freenet.de>
+Date: Sun, 29 Jan 2023 11:09:26 +0100
+Subject: [PATCH] tiffcrop: Amend rotateImage() not to toggle the input (main)
+ image width and length parameters when only cropped image sections are
+ rotated. Remove buffptr from region structure because never used.
+
+Closes #492 #493 #494 #495 #499 #518 #519
+---
+ tools/tiffcrop.c | 59 ++++++++++++++++++++++++++++--------------------
+ 1 file changed, 35 insertions(+), 24 deletions(-)
+
+diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
+index ebea7475..519871ec 100644
+--- a/tools/tiffcrop.c
++++ b/tools/tiffcrop.c
+@@ -296,7 +296,6 @@ struct region
+     uint32_t width;    /* width in pixels */
+     uint32_t length;   /* length in pixels */
+     uint32_t buffsize; /* size of buffer needed to hold the cropped region */
+-    unsigned char *buffptr; /* address of start of the region */
+ };
+ 
+ /* Cropping parameters from command line and image data
+@@ -577,7 +576,7 @@ static int rotateContigSamples24bits(uint16_t, uint16_t, uint16_t, uint32_t,
+ static int rotateContigSamples32bits(uint16_t, uint16_t, uint16_t, uint32_t,
+                                      uint32_t, uint32_t, uint8_t *, uint8_t *);
+ static int rotateImage(uint16_t, struct image_data *, uint32_t *, uint32_t *,
+-                       unsigned char **, size_t *);
++                       unsigned char **, size_t *, int);
+ static int mirrorImage(uint16_t, uint16_t, uint16_t, uint32_t, uint32_t,
+                        unsigned char *);
+ static int invertImage(uint16_t, uint16_t, uint16_t, uint32_t, uint32_t,
+@@ -5782,7 +5781,6 @@ static void initCropMasks(struct crop_mask *cps)
+         cps->regionlist[i].width = 0;
+         cps->regionlist[i].length = 0;
+         cps->regionlist[i].buffsize = 0;
+-        cps->regionlist[i].buffptr = NULL;
+         cps->zonelist[i].position = 0;
+         cps->zonelist[i].total = 0;
+     }
+@@ -7266,9 +7264,13 @@ static int correct_orientation(struct image_data *image,
+                       (uint16_t)(image->adjustments & ROTATE_ANY));
+             return (-1);
+         }
+-
+-        if (rotateImage(rotation, image, &image->width, &image->length,
+-                        work_buff_ptr, NULL))
++        /* Dummy variable in order not to switch two times the
++         * image->width,->length within rotateImage(),
++         * but switch xres, yres there. */
++        uint32_t width = image->width;
++        uint32_t length = image->length;
++        if (rotateImage(rotation, image, &width, &length, work_buff_ptr, NULL,
++                        TRUE))
+         {
+             TIFFError("correct_orientation", "Unable to rotate image");
+             return (-1);
+@@ -7377,7 +7379,6 @@ static int extractCompositeRegions(struct image_data *image,
+         /* These should not be needed for composite images */
+         crop->regionlist[i].width = crop_width;
+         crop->regionlist[i].length = crop_length;
+-        crop->regionlist[i].buffptr = crop_buff;
+ 
+         src_rowsize = ((img_width * bps * spp) + 7) / 8;
+         dst_rowsize = (((crop_width * bps * count) + 7) / 8);
+@@ -7640,7 +7641,6 @@ static int extractSeparateRegion(struct image_data *image,
+ 
+     crop->regionlist[region].width = crop_width;
+     crop->regionlist[region].length = crop_length;
+-    crop->regionlist[region].buffptr = crop_buff;
+ 
+     src = read_buff;
+     dst = crop_buff;
+@@ -8635,7 +8635,8 @@ static int processCropSelections(struct image_data *image,
+              * accordingly. */
+             size_t rot_buf_size = 0;
+             if (rotateImage(crop->rotation, image, &crop->combined_width,
+-                            &crop->combined_length, &crop_buff, &rot_buf_size))
++                            &crop->combined_length, &crop_buff, &rot_buf_size,
++                            FALSE))
+             {
+                 TIFFError("processCropSelections",
+                           "Failed to rotate composite regions by %" PRIu32
+@@ -8759,9 +8760,10 @@ static int processCropSelections(struct image_data *image,
+                  * its size individually. Therefore, seg_buffs size  needs to be
+                  * updated accordingly. */
+                 size_t rot_buf_size = 0;
+-                if (rotateImage(
+-                        crop->rotation, image, &crop->regionlist[i].width,
+-                        &crop->regionlist[i].length, &crop_buff, &rot_buf_size))
++                if (rotateImage(crop->rotation, image,
++                                &crop->regionlist[i].width,
++                                &crop->regionlist[i].length, &crop_buff,
++                                &rot_buf_size, FALSE))
+                 {
+                     TIFFError("processCropSelections",
+                               "Failed to rotate crop region by %" PRIu16
+@@ -8905,7 +8907,7 @@ static int createCroppedImage(struct image_data *image, struct crop_mask *crop,
+         CROP_ROTATE) /* rotate should be last as it can reallocate the buffer */
+     {
+         if (rotateImage(crop->rotation, image, &crop->combined_width,
+-                        &crop->combined_length, crop_buff_ptr, NULL))
++                        &crop->combined_length, crop_buff_ptr, NULL, TRUE))
+         {
+             TIFFError("createCroppedImage",
+                       "Failed to rotate image or cropped selection by %" PRIu16
+@@ -9621,7 +9623,8 @@ static int rotateContigSamples32bits(uint16_t rotation, uint16_t spp,
+ /* Rotate an image by a multiple of 90 degrees clockwise */
+ static int rotateImage(uint16_t rotation, struct image_data *image,
+                        uint32_t *img_width, uint32_t *img_length,
+-                       unsigned char **ibuff_ptr, size_t *rot_buf_size)
++                       unsigned char **ibuff_ptr, size_t *rot_buf_size,
++                       int rot_image_params)
+ {
+     int shift_width;
+     uint32_t bytes_per_pixel, bytes_per_sample;
+@@ -9869,11 +9872,15 @@ static int rotateImage(uint16_t rotation, struct image_data *image,
+ 
+             *img_width = length;
+             *img_length = width;
+-            image->width = length;
+-            image->length = width;
+-            res_temp = image->xres;
+-            image->xres = image->yres;
+-            image->yres = res_temp;
++            /* Only toggle image parameters if whole input image is rotated. */
++            if (rot_image_params)
++            {
++                image->width = length;
++                image->length = width;
++                res_temp = image->xres;
++                image->xres = image->yres;
++                image->yres = res_temp;
++            }
+             break;
+ 
+         case 270:
+@@ -9956,11 +9963,15 @@ static int rotateImage(uint16_t rotation, struct image_data *image,
+ 
+             *img_width = length;
+             *img_length = width;
+-            image->width = length;
+-            image->length = width;
+-            res_temp = image->xres;
+-            image->xres = image->yres;
+-            image->yres = res_temp;
++            /* Only toggle image parameters if whole input image is rotated. */
++            if (rot_image_params)
++            {
++                image->width = length;
++                image->length = width;
++                res_temp = image->xres;
++                image->xres = image->yres;
++                image->yres = res_temp;
++            }
+             break;
+         default:
+             break;
+-- 
+GitLab

diff --git a/media-libs/tiff/files/tiff-4.5.0-CVE-2023-0800-CVE-2023-0801-CVE-2023-0802-CVE-2023-0803-CVE-2023-0804.patch b/media-libs/tiff/files/tiff-4.5.0-CVE-2023-0800-CVE-2023-0801-CVE-2023-0802-CVE-2023-0803-CVE-2023-0804.patch
new file mode 100644
index 000000000000..41fe439f9159
--- /dev/null
+++ b/media-libs/tiff/files/tiff-4.5.0-CVE-2023-0800-CVE-2023-0801-CVE-2023-0802-CVE-2023-0803-CVE-2023-0804.patch
@@ -0,0 +1,131 @@
+Index: tiff-4.5.0/tools/tiffcrop.c
+===================================================================
+Upstream commit:
+https://gitlab.com/libtiff/libtiff/-/commit/33aee1275d9d1384791d2206776eb8152d397f00
+From 82a7fbb1fa7228499ffeb3a57a1d106a9626d57c Mon Sep 17 00:00:00 2001
+From: Su Laus <sulau@freenet.de>
+Date: Sun, 5 Feb 2023 15:53:15 +0000
+Subject: [PATCH] tiffcrop: added check for assumption on composite images
+ (fixes #496)
+
+tiffcrop: For composite images with more than one region, the combined_length or combined_width always needs to be equal, respectively. Otherwise, even the first section/region copy action might cause buffer overrun. This is now checked before the first copy action.
+
+Closes #496, #497, #498, #500, #501.
+---
+ tools/tiffcrop.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 66 insertions(+), 2 deletions(-)
+
+diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
+index 84e26ac6..480b927c 100644
+--- a/tools/tiffcrop.c
++++ b/tools/tiffcrop.c
+@@ -5935,18 +5935,40 @@ static int computeInputPixelOffsets(struct crop_mask *crop,
+ 
+             crop->regionlist[i].buffsize = buffsize;
+             crop->bufftotal += buffsize;
++
++            /* For composite images with more than one region, the
++             * combined_length or combined_width always needs to be equal,
++             * respectively.
++             * Otherwise, even the first section/region copy
++             * action might cause buffer overrun. */
+             if (crop->img_mode == COMPOSITE_IMAGES)
+             {
+                 switch (crop->edge_ref)
+                 {
+                     case EDGE_LEFT:
+                     case EDGE_RIGHT:
++                        if (i > 0 && zlength != crop->combined_length)
++                        {
++                            TIFFError(
++                                "computeInputPixelOffsets",
++                                "Only equal length regions can be combined for "
++                                "-E left or right");
++                            return (-1);
++                        }
+                         crop->combined_length = zlength;
+                         crop->combined_width += zwidth;
+                         break;
+                     case EDGE_BOTTOM:
+                     case EDGE_TOP: /* width from left, length from top */
+                     default:
++                        if (i > 0 && zwidth != crop->combined_width)
++                        {
++                            TIFFError("computeInputPixelOffsets",
++                                      "Only equal width regions can be "
++                                      "combined for -E "
++                                      "top or bottom");
++                            return (-1);
++                        }
+                         crop->combined_width = zwidth;
+                         crop->combined_length += zlength;
+                         break;
+@@ -7301,6 +7323,46 @@ static int extractCompositeRegions(struct image_data *image,
+     crop->combined_width = 0;
+     crop->combined_length = 0;
+ 
++    /* If there is more than one region, check beforehand whether all the width
++     * and length values of the regions are the same, respectively. */
++    switch (crop->edge_ref)
++    {
++        default:
++        case EDGE_TOP:
++        case EDGE_BOTTOM:
++            for (i = 1; i < crop->selections; i++)
++            {
++                uint32_t crop_width0 =
++                    crop->regionlist[i - 1].x2 - crop->regionlist[i - 1].x1 + 1;
++                uint32_t crop_width1 =
++                    crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1;
++                if (crop_width0 != crop_width1)
++                {
++                    TIFFError("extractCompositeRegions",
++                              "Only equal width regions can be combined for -E "
++                              "top or bottom");
++                    return (1);
++                }
++            }
++            break;
++        case EDGE_LEFT:
++        case EDGE_RIGHT:
++            for (i = 1; i < crop->selections; i++)
++            {
++                uint32_t crop_length0 =
++                    crop->regionlist[i - 1].y2 - crop->regionlist[i - 1].y1 + 1;
++                uint32_t crop_length1 =
++                    crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1;
++                if (crop_length0 != crop_length1)
++                {
++                    TIFFError("extractCompositeRegions",
++                              "Only equal length regions can be combined for "
++                              "-E left or right");
++                    return (1);
++                }
++            }
++    }
++
+     for (i = 0; i < crop->selections; i++)
+     {
+         /* rows, columns, width, length are expressed in pixels */
+@@ -7325,7 +7387,8 @@ static int extractCompositeRegions(struct image_data *image,
+             default:
+             case EDGE_TOP:
+             case EDGE_BOTTOM:
+-                if ((i > 0) && (crop_width != crop->regionlist[i - 1].width))
++                if ((crop->selections > i + 1) &&
++                    (crop_width != crop->regionlist[i + 1].width))
+                 {
+                     TIFFError("extractCompositeRegions",
+                               "Only equal width regions can be combined for -E "
+@@ -7418,7 +7481,8 @@ static int extractCompositeRegions(struct image_data *image,
+             case EDGE_LEFT: /* splice the pieces of each row together, side by
+                                side */
+             case EDGE_RIGHT:
+-                if ((i > 0) && (crop_length != crop->regionlist[i - 1].length))
++                if ((crop->selections > i + 1) &&
++                    (crop_length != crop->regionlist[i + 1].length))
+                 {
+                     TIFFError("extractCompositeRegions",
+                               "Only equal length regions can be combined for "
+-- 
+GitLab

diff --git a/media-libs/tiff/tiff-4.5.0-r2.ebuild b/media-libs/tiff/tiff-4.5.0-r2.ebuild
new file mode 100644
index 000000000000..00f6bb711511
--- /dev/null
+++ b/media-libs/tiff/tiff-4.5.0-r2.ebuild
@@ -0,0 +1,92 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+QA_PKGCONFIG_VERSION="$(ver_cut 1-3)"
+
+# Release signer can vary per version but not clear if others will be doing
+# them in future, so gone with Even Rouault for now as he does other geosci
+# stuff too like PROJ, GDAL. Previous release manager of TIFF was
+# GraphicsMagick maintainer Bob Friesenhahn. Please be careful when verifying
+# who made releases.
+VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/rouault.asc
+inherit autotools multilib-minimal verify-sig flag-o-matic
+
+MY_P="${P/_rc/rc}"
+DESCRIPTION="Tag Image File Format (TIFF) library"
+HOMEPAGE="http://libtiff.maptools.org"
+SRC_URI="https://download.osgeo.org/libtiff/${MY_P}.tar.xz"
+SRC_URI+=" verify-sig? ( https://download.osgeo.org/libtiff/${MY_P}.tar.xz.sig )"
+S="${WORKDIR}/${PN}-$(ver_cut 1-3)"
+
+LICENSE="libtiff"
+SLOT="0/6"
+if [[ ${PV} != *_rc* ]] ; then
+	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+fi
+IUSE="+cxx jbig jpeg lzma static-libs test webp zlib zstd"
+RESTRICT="!test? ( test )"
+
+# bug #483132
+REQUIRED_USE="test? ( jpeg )"
+
+RDEPEND="jbig? ( >=media-libs/jbigkit-2.1:=[${MULTILIB_USEDEP}] )
+	jpeg? ( media-libs/libjpeg-turbo:=[${MULTILIB_USEDEP}] )
+	lzma? ( >=app-arch/xz-utils-5.0.5-r1[${MULTILIB_USEDEP}] )
+	webp? ( media-libs/libwebp:=[${MULTILIB_USEDEP}] )
+	zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )
+	zstd? ( >=app-arch/zstd-1.3.7-r1:=[${MULTILIB_USEDEP}] )"
+DEPEND="${RDEPEND}"
+BDEPEND="verify-sig? ( sec-keys/openpgp-keys-evenrouault )"
+
+MULTILIB_WRAPPED_HEADERS=(
+	/usr/include/tiffconf.h
+)
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-4.5.0_rc1-skip-tools-tests-multilib.patch
+	"${FILESDIR}"/${PN}-4.5.0-CVE-2022-48281.patch
+	"${FILESDIR}"/${PN}-4.5.0-CVE-2023-0795-CVE-2023-0796-CVE-2023-0797-CVE-2023-0798-CVE-2023-0799.patch
+	"${FILESDIR}"/${PN}-4.5.0-CVE-2023-0800-CVE-2023-0801-CVE-2023-0802-CVE-2023-0803-CVE-2023-0804.patch
+)
+
+src_prepare() {
+	default
+
+	# Added to fix cross-compilation
+	#elibtoolize
+
+	# For skip-tools-tests-multilib.patch
+	eautoreconf
+}
+
+multilib_src_configure() {
+	append-lfs-flags
+
+	local myeconfargs=(
+		--disable-sphinx
+		--without-x
+		--with-docdir="${EPREFIX}"/usr/share/doc/${PF}
+		$(use_enable cxx)
+		$(use_enable jbig)
+		$(use_enable jpeg)
+		$(use_enable lzma)
+		$(use_enable static-libs static)
+		$(use_enable test tests)
+		$(use_enable webp)
+		$(use_enable zlib)
+		$(use_enable zstd)
+
+		$(multilib_native_enable docs)
+		$(multilib_native_enable contrib)
+		$(multilib_native_enable tools)
+	)
+
+	ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+}
+
+multilib_src_install_all() {
+	find "${ED}" -type f -name '*.la' -delete || die
+	rm "${ED}"/usr/share/doc/${PF}/{README*,RELEASE-DATE,TODO,VERSION} || die
+}


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-02-22 16:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-20 14:29 [gentoo-commits] repo/gentoo:master commit in: media-libs/tiff/, media-libs/tiff/files/ Lars Wendler
  -- strict thread matches above, loose matches on Subject: below --
2023-02-22 16:23 Sam James
2023-02-22 16:21 Sam James
2022-12-10  4:10 Sam James
2022-12-01  7:17 Sam James
2019-11-03 13:46 Mikle Kolyada
2019-09-03 19:46 Aaron Bauman
2019-08-05  0:12 Aaron Bauman
2018-05-29  1:04 Mike Frysinger
2017-11-19 20:52 Lars Wendler
2017-05-22  7:35 Lars Wendler
2017-04-12 19:30 Mike Frysinger
2017-04-10 21:49 Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox