Yocto 2.4

Move OpenBMC to Yocto 2.4(rocko)

Tested: Built and verified Witherspoon and Palmetto images
Change-Id: I12057b18610d6fb0e6903c60213690301e9b0c67
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10093.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10093.patch
deleted file mode 100644
index e09bb7f..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10093.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From 787c0ee906430b772f33ca50b97b8b5ca070faec Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-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
-
-Upstream-Status: Backport
-CVE: CVE-2016-10093
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
-
----
- ChangeLog      | 7 +++++++
- tools/tiffcp.c | 6 +++---
- 2 files changed, 10 insertions(+), 3 deletions(-)
-
-Index: tiff-4.0.7/tools/tiffcp.c
-===================================================================
---- tiff-4.0.7.orig/tools/tiffcp.c
-+++ tiff-4.0.7/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(readContigTilesIntoBuffe
- 	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(readContigTilesIntoBuffe
- 				status = 0;
- 				goto done;
- 			}
--			if (colb + tilew > imagew) {
-+			if (colb > iskew) {
- 				uint32 width = imagew - colb;
- 				uint32 oskew = tilew - width;
- 				cpStripToTile(bufp + colb,
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10266.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10266.patch
deleted file mode 100644
index e1c90c6..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10266.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-From 1855407c4e5a27ade006b26c2dec8a31745c356e Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-Date: Fri, 2 Dec 2016 21:56:56 +0000
-Subject: [PATCH] * libtiff/tif_read.c, libtiff/tiffiop.h: fix uint32 overflow
- in TIFFReadEncodedStrip() that caused an integer division by zero. Reported
- by Agostino Sarubbo. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2596
-
-Upstream-Status: Backport
-
-CVE: CVE-2016-10266
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
----
- ChangeLog          | 7 +++++++
- libtiff/tif_read.c | 2 +-
- libtiff/tiffiop.h  | 4 ++++
- 3 files changed, 12 insertions(+), 1 deletion(-)
-
-Index: tiff-4.0.7/ChangeLog
-===================================================================
---- tiff-4.0.7.orig/ChangeLog
-+++ tiff-4.0.7/ChangeLog
-@@ -1,3 +1,10 @@
-+2016-12-02 Even Rouault <even.rouault at spatialys.com>
-+
-+       * 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
-+
- 2017-07-15  Even Rouault <even.rouault at spatialys.com>
- 
- 	* tools/tiff2pdf.c: prevent heap buffer overflow write in "Raw"
-Index: tiff-4.0.7/libtiff/tif_read.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_read.c
-+++ tiff-4.0.7/libtiff/tif_read.c
-@@ -346,7 +346,7 @@ TIFFReadEncodedStrip(TIFF* tif, uint32 s
- 	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;
-Index: tiff-4.0.7/libtiff/tiffiop.h
-===================================================================
---- tiff-4.0.7.orig/libtiff/tiffiop.h
-+++ tiff-4.0.7/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)))
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10267.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10267.patch
deleted file mode 100644
index f4c5791..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10267.patch
+++ /dev/null
@@ -1,70 +0,0 @@
-From f8203c7ab1dbd7b5c59158576bec7da90191f42f Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-Date: Sat, 3 Dec 2016 11:15:18 +0000
-Subject: [PATCH] * libtiff/tif_ojpeg.c: make OJPEGDecode() early exit in case
- of failure in OJPEGPreDecode(). This will avoid a divide by zero, and
- potential other issues. Reported by Agostino Sarubbo. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2611
-
-Upstream-Status: Backport
-
-CVE: CVE-2016-10267
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
----
- ChangeLog           | 7 +++++++
- libtiff/tif_ojpeg.c | 8 ++++++++
- 2 files changed, 15 insertions(+)
-
-diff --git a/ChangeLog b/ChangeLog
-index 7339c1a..66fbcdc 100644
---- a/ChangeLog
-+++ b/ChangeLog
-@@ -1,3 +1,10 @@
-+2016-12-03 Even Rouault <even.rouault at spatialys.com>
-+ 
-+	* 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
-+
- 2016-12-02 Even Rouault <even.rouault at spatialys.com>
- 
- 	* libtiff/tif_read.c, libtiff/tiffiop.h: fix uint32 overflow in
-diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c
-index 1ccc3f9..f19e8fd 100644
---- a/libtiff/tif_ojpeg.c
-+++ b/libtiff/tif_ojpeg.c
-@@ -244,6 +244,7 @@ typedef enum {
- 
- typedef struct {
- 	TIFF* tif;
-+        int decoder_ok;
- 	#ifndef LIBJPEG_ENCAP_EXTERNAL
- 	JMP_BUF exit_jmpbuf;
- 	#endif
-@@ -722,6 +723,7 @@ OJPEGPreDecode(TIFF* tif, uint16 s)
- 		}
- 		sp->write_curstrile++;
- 	}
-+	sp->decoder_ok = 1;
- 	return(1);
- }
- 
-@@ -784,8 +786,14 @@ OJPEGPreDecodeSkipScanlines(TIFF* tif)
- static int
- OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
- {
-+        static const char module[]="OJPEGDecode";
- 	OJPEGState* sp=(OJPEGState*)tif->tif_data;
- 	(void)s;
-+        if( !sp->decoder_ok )
-+        {
-+            TIFFErrorExt(tif->tif_clientdata,module,"Cannot decode: decoder not correctly initialized");
-+            return 0;
-+        }
- 	if (sp->libjpeg_jpeg_query_style==0)
- 	{
- 		if (OJPEGDecodeRaw(tif,buf,cc)==0)
--- 
-1.9.1
-
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10268.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10268.patch
deleted file mode 100644
index 03b982a..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10268.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From 5397a417e61258c69209904e652a1f409ec3b9df Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-Date: Fri, 2 Dec 2016 22:13:32 +0000
-Subject: [PATCH] * tools/tiffcp.c: avoid uint32 underflow in cpDecodedStrips
- that can cause various issues, such as buffer overflows in the library.
- Reported by Agostino Sarubbo. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2598
-
-Upstream-Status: Backport
-CVE: CVE-2016-10268
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
-
----
- ChangeLog      | 7 +++++++
- tools/tiffcp.c | 2 +-
- 2 files changed, 8 insertions(+), 1 deletion(-)
-
-Index: tiff-4.0.7/tools/tiffcp.c
-===================================================================
---- tiff-4.0.7.orig/tools/tiffcp.c
-+++ tiff-4.0.7/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
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10269.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10269.patch
deleted file mode 100644
index d9f4a15..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10269.patch
+++ /dev/null
@@ -1,131 +0,0 @@
-From 10f72dd232849d0142a0688bcc9aa71025f120a3 Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-Date: Fri, 2 Dec 2016 23:05:51 +0000
-Subject: [PATCH 2/4] * 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
-
-Upstream-Status: Backport
-
-CVE: CVE-2016-10269
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
----
- ChangeLog              | 10 ++++++++++
- libtiff/tif_luv.c      | 18 ++++++++++++++----
- libtiff/tif_pixarlog.c | 17 +++++++++++++++--
- 3 files changed, 39 insertions(+), 6 deletions(-)
-
-diff --git a/ChangeLog b/ChangeLog
-index 2e913b6..0a2c2a7 100644
---- a/ChangeLog
-+++ b/ChangeLog
-@@ -1,4 +1,14 @@
- 2016-12-03 Even Rouault <even.rouault at spatialys.com>
-+
-+	* 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
-+
-+2016-12-03 Even Rouault <even.rouault at spatialys.com>
-  
- 	* 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.
-diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c
-index f68a9b1..e6783db 100644
---- a/libtiff/tif_luv.c
-+++ b/libtiff/tif_luv.c
-@@ -158,6 +158,7 @@
- typedef struct logLuvState LogLuvState;
- 
- struct logLuvState {
-+        int                     encoder_state;  /* 1 if encoder correctly initialized */
- 	int                     user_datafmt;   /* user data format */
- 	int                     encode_meth;    /* encoding method */
- 	int                     pixel_size;     /* bytes per pixel */
-@@ -1552,6 +1553,7 @@ LogLuvSetupEncode(TIFF* tif)
- 		    td->td_photometric, "must be either LogLUV or LogL");
- 		break;
- 	}
-+	sp->encoder_state = 1;
- 	return (1);
- notsupported:
- 	TIFFErrorExt(tif->tif_clientdata, module,
-@@ -1563,19 +1565,27 @@ notsupported:
- static void
- LogLuvClose(TIFF* tif)
- {
-+        LogLuvState* sp = (LogLuvState*) tif->tif_data;
- 	TIFFDirectory *td = &tif->tif_dir;
- 
-+	assert(sp != 0);
- 	/*
- 	 * For consistency, we always want to write out the same
- 	 * bitspersample and sampleformat for our TIFF file,
- 	 * regardless of the data format being used by the application.
- 	 * Since this routine is called after tags have been set but
- 	 * before they have been recorded in the file, we reset them here.
-+         * Note: this is really a nasty approach. See PixarLogClose
- 	 */
--	td->td_samplesperpixel =
--	    (td->td_photometric == PHOTOMETRIC_LOGL) ? 1 : 3;
--	td->td_bitspersample = 16;
--	td->td_sampleformat = SAMPLEFORMAT_INT;
-+        if( sp->encoder_state )
-+        {
-+            /* See PixarLogClose. Might avoid issues with tags whose size depends
-+             * on those below, but not completely sure this is enough. */
-+            td->td_samplesperpixel =
-+                (td->td_photometric == PHOTOMETRIC_LOGL) ? 1 : 3;
-+            td->td_bitspersample = 16;
-+            td->td_sampleformat = SAMPLEFORMAT_INT;
-+        }
- }
- 
- static void
-diff --git a/libtiff/tif_pixarlog.c b/libtiff/tif_pixarlog.c
-index d1246c3..aa99bc9 100644
---- a/libtiff/tif_pixarlog.c
-+++ b/libtiff/tif_pixarlog.c
-@@ -1233,8 +1233,10 @@ PixarLogPostEncode(TIFF* tif)
- static void
- PixarLogClose(TIFF* tif)
- {
-+        PixarLogState* sp = (PixarLogState*) tif->tif_data;
- 	TIFFDirectory *td = &tif->tif_dir;
- 
-+	assert(sp != 0);
- 	/* In a really sneaky (and really incorrect, and untruthful, and
- 	 * troublesome, and error-prone) maneuver that completely goes against
- 	 * the spirit of TIFF, and breaks TIFF, on close, we covertly
-@@ -1243,8 +1245,19 @@ PixarLogClose(TIFF* tif)
- 	 * readers that don't know about PixarLog, or how to set
- 	 * the PIXARLOGDATFMT pseudo-tag.
- 	 */
--	td->td_bitspersample = 8;
--	td->td_sampleformat = SAMPLEFORMAT_UINT;
-+
-+        if (sp->state&PLSTATE_INIT) {
-+            /* We test the state to avoid an issue such as in
-+             * http://bugzilla.maptools.org/show_bug.cgi?id=2604
-+             * What appends in that case is that the bitspersample is 1 and
-+             * a TransferFunction is set. The size of the TransferFunction
-+             * depends on 1<<bitspersample. So if we increase it, an access
-+             * out of the buffer will happen at directory flushing.
-+             * Another option would be to clear those targs. 
-+             */
-+            td->td_bitspersample = 8;
-+            td->td_sampleformat = SAMPLEFORMAT_UINT;
-+        }
- }
- 
- static void
--- 
-1.9.1
-
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10270.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10270.patch
deleted file mode 100644
index 43ad6ed..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10270.patch
+++ /dev/null
@@ -1,134 +0,0 @@
-From 6e7042c61e300cf9971c645c79d05de974b24308 Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-Date: Sat, 3 Dec 2016 11:02:15 +0000
-Subject: [PATCH 3/4] * 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.
-
-Upstream-Status: Backport
-
-CVE: CVE-2016-10270
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
----
- ChangeLog             | 15 +++++++++++++++
- libtiff/tif_dirread.c | 22 ++++++++++------------
- libtiff/tif_strip.c   |  9 ---------
- 3 files changed, 25 insertions(+), 21 deletions(-)
-
-diff --git a/ChangeLog b/ChangeLog
-index 0a2c2a7..6e30e41 100644
---- a/ChangeLog
-+++ b/ChangeLog
-@@ -1,5 +1,20 @@
- 2016-12-03 Even Rouault <even.rouault at spatialys.com>
- 
-+	* 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.
-+
-+2016-12-03 Even Rouault <even.rouault at spatialys.com>
-+
- 	* 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.
-diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
-index 3eec79c..570d0c3 100644
---- a/libtiff/tif_dirread.c
-+++ b/libtiff/tif_dirread.c
-@@ -5502,8 +5502,7 @@ ChopUpSingleUncompressedStrip(TIFF* tif)
- 	uint64 rowblockbytes;
- 	uint64 stripbytes;
- 	uint32 strip;
--	uint64 nstrips64;
--	uint32 nstrips32;
-+	uint32 nstrips;
- 	uint32 rowsperstrip;
- 	uint64* newcounts;
- 	uint64* newoffsets;
-@@ -5534,18 +5533,17 @@ ChopUpSingleUncompressedStrip(TIFF* tif)
- 	    return;
- 
- 	/*
--	 * never increase the number of strips in an image
-+	 * never increase the number of rows per strip
- 	 */
- 	if (rowsperstrip >= td->td_rowsperstrip)
- 		return;
--	nstrips64 = TIFFhowmany_64(bytecount, stripbytes);
--	if ((nstrips64==0)||(nstrips64>0xFFFFFFFF)) /* something is wonky, do nothing. */
--	    return;
--	nstrips32 = (uint32)nstrips64;
-+        nstrips = TIFFhowmany_32(td->td_imagelength, rowsperstrip);
-+        if( nstrips == 0 )
-+            return;
- 
--	newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips32, sizeof (uint64),
-+	newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64),
- 				"for chopped \"StripByteCounts\" array");
--	newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips32, sizeof (uint64),
-+	newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64),
- 				"for chopped \"StripOffsets\" array");
- 	if (newcounts == NULL || newoffsets == NULL) {
- 		/*
-@@ -5562,18 +5560,18 @@ ChopUpSingleUncompressedStrip(TIFF* tif)
- 	 * Fill the strip information arrays with new bytecounts and offsets
- 	 * that reflect the broken-up format.
- 	 */
--	for (strip = 0; strip < nstrips32; strip++) {
-+	for (strip = 0; strip < nstrips; strip++) {
- 		if (stripbytes > bytecount)
- 			stripbytes = bytecount;
- 		newcounts[strip] = stripbytes;
--		newoffsets[strip] = offset;
-+		newoffsets[strip] = stripbytes ? offset : 0;
- 		offset += stripbytes;
- 		bytecount -= stripbytes;
- 	}
- 	/*
- 	 * Replace old single strip info with multi-strip info.
- 	 */
--	td->td_stripsperimage = td->td_nstrips = nstrips32;
-+	td->td_stripsperimage = td->td_nstrips = nstrips;
- 	TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
- 
- 	_TIFFfree(td->td_stripbytecount);
-diff --git a/libtiff/tif_strip.c b/libtiff/tif_strip.c
-index 4c46ecf..1676e47 100644
---- a/libtiff/tif_strip.c
-+++ b/libtiff/tif_strip.c
-@@ -63,15 +63,6 @@ TIFFNumberOfStrips(TIFF* tif)
- 	TIFFDirectory *td = &tif->tif_dir;
- 	uint32 nstrips;
- 
--    /* If the value was already computed and store in td_nstrips, then return it,
--       since ChopUpSingleUncompressedStrip might have altered and resized the
--       since the td_stripbytecount and td_stripoffset arrays to the new value
--       after the initial affectation of td_nstrips = TIFFNumberOfStrips() in
--       tif_dirread.c ~line 3612.
--       See http://bugzilla.maptools.org/show_bug.cgi?id=2587 */
--    if( td->td_nstrips )
--        return td->td_nstrips;
--
- 	nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
- 	     TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
- 	if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
--- 
-1.9.1
-
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10271.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10271.patch
deleted file mode 100644
index 4fe5bcd..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2016-10271.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From 9657bbe3cdce4aaa90e07d50c1c70ae52da0ba6a Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-Date: Sat, 3 Dec 2016 11:35:56 +0000
-Subject: [PATCH] * tools/tiffcrop.c: fix readContigStripsIntoBuffer() in -i
- (ignore) mode so that the output buffer is correctly incremented to avoid
- write outside bounds. Reported by Agostino Sarubbo. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2620
-
-Upstream-Status: Backport
-CVE: CVE-2016-10271
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
-
----
- ChangeLog        | 7 +++++++
- tools/tiffcrop.c | 2 +-
- 2 files changed, 8 insertions(+), 1 deletion(-)
-
-Index: tiff-4.0.7/tools/tiffcrop.c
-===================================================================
---- tiff-4.0.7.orig/tools/tiffcrop.c
-+++ tiff-4.0.7/tools/tiffcrop.c
-@@ -3698,7 +3698,7 @@ static int readContigStripsIntoBuffer (T
-                                   (unsigned long) strip, (unsigned long)rows);
-                         return 0;
-                 }
--                bufp += bytes_read;
-+                bufp += stripsize;
-         }
- 
-         return 1;
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-10688.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-10688.patch
index ed9c0f5..b0db969 100644
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-10688.patch
+++ b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-10688.patch
@@ -18,10 +18,10 @@
  libtiff/tif_dirwrite.c | 20 ++++++++++++++++----
  2 files changed, 24 insertions(+), 4 deletions(-)
 
-Index: tiff-4.0.7/ChangeLog
-===================================================================
---- tiff-4.0.7.orig/ChangeLog
-+++ tiff-4.0.7/ChangeLog
+diff --git a/ChangeLog b/ChangeLog
+index 0240f0b..42eaeb7 100644
+--- a/ChangeLog
++++ b/ChangeLog
 @@ -1,3 +1,11 @@
 +2017-06-30  Even Rouault <even.rouault at spatialys.com>
 +
@@ -34,11 +34,11 @@
  2017-06-26  Even Rouault <even.rouault at spatialys.com>
  
  	* libtiff/tif_jbig.c: fix memory leak in error code path of JBIGDecode()
-Index: tiff-4.0.7/libtiff/tif_dirwrite.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_dirwrite.c
-+++ tiff-4.0.7/libtiff/tif_dirwrite.c
-@@ -2047,7 +2047,10 @@ TIFFWriteDirectoryTagCheckedLong8(TIFF*
+diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
+index 2967da5..8d6686b 100644
+--- a/libtiff/tif_dirwrite.c
++++ b/libtiff/tif_dirwrite.c
+@@ -2111,7 +2111,10 @@ TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui
  {
  	uint64 m;
  	assert(sizeof(uint64)==8);
@@ -50,7 +50,7 @@
  	m=value;
  	if (tif->tif_flags&TIFF_SWAB)
  		TIFFSwabLong8(&m);
-@@ -2060,7 +2063,10 @@ TIFFWriteDirectoryTagCheckedLong8Array(T
+@@ -2124,7 +2127,10 @@ TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* di
  {
  	assert(count<0x20000000);
  	assert(sizeof(uint64)==8);
@@ -62,7 +62,7 @@
  	if (tif->tif_flags&TIFF_SWAB)
  		TIFFSwabArrayOfLong8(value,count);
  	return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG8,count,count*8,value));
-@@ -2072,7 +2078,10 @@ TIFFWriteDirectoryTagCheckedSlong8(TIFF*
+@@ -2136,7 +2142,10 @@ TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, u
  {
  	int64 m;
  	assert(sizeof(int64)==8);
@@ -74,7 +74,7 @@
  	m=value;
  	if (tif->tif_flags&TIFF_SWAB)
  		TIFFSwabLong8((uint64*)(&m));
-@@ -2085,7 +2094,10 @@ TIFFWriteDirectoryTagCheckedSlong8Array(
+@@ -2149,7 +2158,10 @@ TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* d
  {
  	assert(count<0x20000000);
  	assert(sizeof(int64)==8);
@@ -86,3 +86,6 @@
  	if (tif->tif_flags&TIFF_SWAB)
  		TIFFSwabArrayOfLong8((uint64*)value,count);
  	return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,count,count*8,value));
+-- 
+2.7.4
+
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-13726.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-13726.patch
new file mode 100644
index 0000000..c60ffa6
--- /dev/null
+++ b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-13726.patch
@@ -0,0 +1,54 @@
+From 5317ce215936ce611846557bb104b49d3b4c8345 Mon Sep 17 00:00:00 2001
+From: Even Rouault <even.rouault@spatialys.com>
+Date: Wed, 23 Aug 2017 13:21:41 +0000
+Subject: [PATCH] * libtiff/tif_dirwrite.c: replace assertion related to not
+ finding the SubIFD tag by runtime check. Fixes
+ http://bugzilla.maptools.org/show_bug.cgi?id=2727 Reported by team OWL337
+
+Upstream-Status: Backport
+[https://github.com/vadz/libtiff/commit/f91ca83a21a6a583050e5a5755ce1441b2bf1d7e]
+
+CVE: CVE-2017-13726
+
+Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
+---
+ ChangeLog              | 7 +++++++
+ libtiff/tif_dirwrite.c | 7 ++++++-
+ 2 files changed, 13 insertions(+), 1 deletion(-)
+
+diff --git a/ChangeLog b/ChangeLog
+index 6980da8..3e299d9 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -1,3 +1,10 @@
++2017-08-23  Even Rouault <even.rouault at spatialys.com>
++
++	* libtiff/tif_dirwrite.c: replace assertion related to not finding the
++	SubIFD tag by runtime check.
++	Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2727
++	Reported by team OWL337
++
+ 2017-07-15  Even Rouault <even.rouault at spatialys.com>
+ 
+ 	* tools/tiff2pdf.c: prevent heap buffer overflow write in "Raw"
+diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
+index 8d6686b..14090ae 100644
+--- a/libtiff/tif_dirwrite.c
++++ b/libtiff/tif_dirwrite.c
+@@ -821,7 +821,12 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff)
+ 			TIFFDirEntry* nb;
+ 			for (na=0, nb=dir; ; na++, nb++)
+ 			{
+-				assert(na<ndir);
++				if( na == ndir )
++                                {
++                                    TIFFErrorExt(tif->tif_clientdata,module,
++                                                 "Cannot find SubIFD tag");
++                                    goto bad;
++                                }
+ 				if (nb->tdir_tag==TIFFTAG_SUBIFD)
+ 					break;
+ 			}
+-- 
+2.7.4
+
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-13727.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-13727.patch
new file mode 100644
index 0000000..e228c2f
--- /dev/null
+++ b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-13727.patch
@@ -0,0 +1,65 @@
+From a5e8245cc67646f7b448b4ca29258eaac418102c Mon Sep 17 00:00:00 2001
+From: Even Rouault <even.rouault@spatialys.com>
+Date: Wed, 23 Aug 2017 13:33:42 +0000
+Subject: [PATCH] * libtiff/tif_dirwrite.c: replace assertion to tag value not
+ fitting on uint32 when selecting the value of SubIFD tag by runtime check (in
+ TIFFWriteDirectoryTagSubifd()). Fixes
+ http://bugzilla.maptools.org/show_bug.cgi?id=2728 Reported by team OWL337
+
+SubIFD tag by runtime check (in TIFFWriteDirectorySec())
+
+Upstream-Status: Backport
+[https://github.com/vadz/libtiff/commit/b6af137bf9ef852f1a48a50a5afb88f9e9da01cc]
+
+CVE: CVE-2017-13727
+
+Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
+---
+ ChangeLog              | 10 +++++++++-
+ libtiff/tif_dirwrite.c |  9 ++++++++-
+ 2 files changed, 17 insertions(+), 2 deletions(-)
+
+diff --git a/ChangeLog b/ChangeLog
+index 3e299d9..8f5efe9 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -1,7 +1,15 @@
+ 2017-08-23  Even Rouault <even.rouault at spatialys.com>
+ 
++	* libtiff/tif_dirwrite.c: replace assertion to tag value not fitting
++	on uint32 when selecting the value of SubIFD tag by runtime check
++	(in TIFFWriteDirectoryTagSubifd()).
++	Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2728
++	Reported by team OWL337
++
++2017-08-23  Even Rouault <even.rouault at spatialys.com>
++
+ 	* libtiff/tif_dirwrite.c: replace assertion related to not finding the
+-	SubIFD tag by runtime check.
++	SubIFD tag by runtime check (in TIFFWriteDirectorySec())
+ 	Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2727
+ 	Reported by team OWL337
+ 
+diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
+index 14090ae..f0a4baa 100644
+--- a/libtiff/tif_dirwrite.c
++++ b/libtiff/tif_dirwrite.c
+@@ -1949,7 +1949,14 @@ TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir)
+ 		for (p=0; p < tif->tif_dir.td_nsubifd; p++)
+ 		{
+                         assert(pa != 0);
+-			assert(*pa <= 0xFFFFFFFFUL);
++
++                        /* Could happen if an classicTIFF has a SubIFD of type LONG8 (which is illegal) */
++                        if( *pa > 0xFFFFFFFFUL)
++                        {
++                            TIFFErrorExt(tif->tif_clientdata,module,"Illegal value for SubIFD tag");
++                            _TIFFfree(o);
++                            return(0);
++                        }
+ 			*pb++=(uint32)(*pa++);
+ 		}
+ 		n=TIFFWriteDirectoryTagCheckedIfdArray(tif,ndir,dir,TIFFTAG_SUBIFD,tif->tif_dir.td_nsubifd,o);
+-- 
+2.7.4
+
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7592.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7592.patch
deleted file mode 100644
index 5b80445..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7592.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 48780b4fcc425cddc4ef8ffdf536f96a0d1b313b Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-Date: Wed, 11 Jan 2017 16:38:26 +0000
-Subject: [PATCH] * libtiff/tif_getimage.c: add explicit uint32 cast in putagreytile to
-avoid UndefinedBehaviorSanitizer warning.
-Patch by Nicolas Pena.
-Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2658
-
-Upstream-Status: Backport
-CVE: CVE-2017-7592
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
-
-Index: tiff-4.0.7/ChangeLog
-===================================================================
---- tiff-4.0.7.orig/ChangeLog	2017-04-24 14:25:10.143926025 +0530
-+++ tiff-4.0.7/ChangeLog	2017-04-24 15:20:21.291839230 +0530
-@@ -1,3 +1,10 @@
-+2017-01-11 Even Rouault <even.rouault at spatialys.com>
-+
-+	* libtiff/tif_getimage.c: add explicit uint32 cast in putagreytile to
-+	avoid UndefinedBehaviorSanitizer warning.
-+	Patch by Nicolas Pena.
-+	Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2658
-+
- 2016-12-03 Even Rouault <even.rouault at spatialys.com>
- 
- 	* libtiff/tif_dirread.c: modify ChopUpSingleUncompressedStrip() to
-Index: tiff-4.0.7/libtiff/tif_getimage.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_getimage.c	2016-11-18 08:17:45.000000000 +0530
-+++ tiff-4.0.7/libtiff/tif_getimage.c	2017-04-24 15:17:46.671843283 +0530
-@@ -1305,7 +1305,7 @@
-     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;
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7593.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7593.patch
deleted file mode 100644
index 380dfcb..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7593.patch
+++ /dev/null
@@ -1,98 +0,0 @@
-From d60332057b9575ada4f264489582b13e30137be1 Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-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
-
-Upstream-Status: Backport
-
-CVE: CVE-2017-7593
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
-Index: tiff-4.0.7/ChangeLog
-===================================================================
---- tiff-4.0.7.orig/ChangeLog	2017-04-25 19:03:20.584155452 +0530
-+++ tiff-4.0.7/ChangeLog	2017-04-26 12:09:41.986866896 +0530
-@@ -44,6 +44,14 @@
- 
- 2017-01-11 Even Rouault <even.rouault at spatialys.com>
- 
-+	* libtiff/tiffiop.h, tif_unix.c, tif_win32.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
-+
-+2017-01-11 Even Rouault <even.rouault at spatialys.com>
-+
- 	* libtiff/tif_getimage.c: add explicit uint32 cast in putagreytile to
- 	avoid UndefinedBehaviorSanitizer warning.
- 	Patch by Nicolas Pena.
-Index: tiff-4.0.7/libtiff/tif_read.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_read.c	2017-04-25 19:03:20.584155452 +0530
-+++ tiff-4.0.7/libtiff/tif_read.c	2017-04-26 12:11:42.814863729 +0530
-@@ -986,7 +986,9 @@
- 				 "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) {
-Index: tiff-4.0.7/libtiff/tif_unix.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_unix.c	2015-08-29 03:46:22.707817041 +0530
-+++ tiff-4.0.7/libtiff/tif_unix.c	2017-04-26 12:13:07.442861510 +0530
-@@ -316,6 +316,14 @@
- 	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)
- {
-Index: tiff-4.0.7/libtiff/tif_win32.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_win32.c	2015-08-29 03:46:22.730570169 +0530
-+++ tiff-4.0.7/libtiff/tif_win32.c	2017-04-26 12:14:12.918859794 +0530
-@@ -360,6 +360,14 @@
- 	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)
- {
-Index: tiff-4.0.7/libtiff/tiffio.h
-===================================================================
---- tiff-4.0.7.orig/libtiff/tiffio.h	2016-01-24 21:09:51.894442042 +0530
-+++ tiff-4.0.7/libtiff/tiffio.h	2017-04-26 12:15:55.034857117 +0530
-@@ -293,6 +293,7 @@
-  */
- 
- 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);
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7594-p1.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7594-p1.patch
deleted file mode 100644
index 5c7e460..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7594-p1.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-rom 8283e4d1b7e53340684d12932880cbcbaf23a8c1 Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-Date: Thu, 12 Jan 2017 17:43:25 +0000
-
-* libtiff/tif_ojpeg.c: fix leak in OJPEGReadHeaderInfoSecTablesAcTable
-  when read fails.
-  Patch by Nicolas Pena.
-  Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2659
-
-Upstream-Status: Backport
-
-CVE: CVE-2017-7594 #patch1
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
-Index: tiff-4.0.7/ChangeLog
-===================================================================
---- tiff-4.0.7.orig/ChangeLog	2017-04-24 16:13:15.000000000 +0530
-+++ tiff-4.0.7/ChangeLog	2017-04-24 16:50:26.465897646 +0530
-@@ -1,3 +1,10 @@
-+2017-01-12 Even Rouault <even.rouault at spatialys.com>
-+
-+	* libtiff/tif_ojpeg.c: fix leak in OJPEGReadHeaderInfoSecTablesAcTable
-+	when read fails.
-+	Patch by Nicolás Peña.
-+	Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2659
-+
- 2017-01-11 Even Rouault <even.rouault at spatialys.com>
- 
- 	* libtiff/tif_getimage.c: add explicit uint32 cast in putagreytile to
-Index: tiff-4.0.7/libtiff/tif_ojpeg.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_ojpeg.c	2017-04-24 16:02:29.817973051 +0530
-+++ tiff-4.0.7/libtiff/tif_ojpeg.c	2017-04-24 16:52:27.349894477 +0530
-@@ -1918,7 +1918,10 @@
- 				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);
- 		}
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7594-p2.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7594-p2.patch
deleted file mode 100644
index 82a19c6..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7594-p2.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-From 2ea32f7372b65c24b2816f11c04bf59b5090d05b Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-Date: Thu, 12 Jan 2017 19:23:20 +0000
-Subject: [PATCH 2/2] * libtiff/tif_ojpeg.c: fix leak in
- OJPEGReadHeaderInfoSecTablesQTable, OJPEGReadHeaderInfoSecTablesDcTable and
- OJPEGReadHeaderInfoSecTablesAcTable
-
-Upstream-status: Backport
-
-CVE: CVE-2017-7594 #patch2
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
-Index: tiff-4.0.7/ChangeLog
-===================================================================
---- tiff-4.0.7.orig/ChangeLog	2017-04-24 16:50:26.465897646 +0530
-+++ tiff-4.0.7/ChangeLog	2017-04-24 16:56:20.685888360 +0530
-@@ -1,6 +1,7 @@
- 2017-01-12 Even Rouault <even.rouault at spatialys.com>
- 
--	* libtiff/tif_ojpeg.c: fix leak in OJPEGReadHeaderInfoSecTablesAcTable
-+	* libtiff/tif_ojpeg.c: fix leak in OJPEGReadHeaderInfoSecTablesQTable,
-+	OJPEGReadHeaderInfoSecTablesDcTable and OJPEGReadHeaderInfoSecTablesAcTable
- 	when read fails.
- 	Patch by Nicolás Peña.
- 	Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2659
-Index: tiff-4.0.7/libtiff/tif_ojpeg.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_ojpeg.c	2017-04-24 16:52:27.349894477 +0530
-+++ tiff-4.0.7/libtiff/tif_ojpeg.c	2017-04-24 16:59:20.001883660 +0530
-@@ -1790,7 +1790,10 @@
- 			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 @@
- 				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);
- 		}
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7595.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7595.patch
deleted file mode 100644
index 851a37f..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7595.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-commit 618d490090bfd10e613ac574ecff31a293904b44
-Author: erouault <erouault>
-Date:   Wed Jan 11 12:15:01 2017 +0000
-
-    * 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
-
-Upstream-Status: Backport
-
-CVE: CVE-2017-7595
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
-
-Index: tiff-4.0.7/ChangeLog
-===================================================================
---- tiff-4.0.7.orig/ChangeLog	2017-04-24 17:31:40.013832807 +0530
-+++ tiff-4.0.7/ChangeLog	2017-04-24 18:03:34.769782616 +0530
-@@ -8,6 +8,12 @@
- 
- 2017-01-11 Even Rouault <even.rouault at spatialys.com>
- 
-+	* 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
-+
-+2017-01-11 Even Rouault <even.rouault at spatialys.com>
-+
- 	* libtiff/tif_getimage.c: add explicit uint32 cast in putagreytile to
- 	avoid UndefinedBehaviorSanitizer warning.
- 	Patch by Nicolas Pena.
-Index: tiff-4.0.7/libtiff/tif_jpeg.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_jpeg.c	2016-01-24 21:09:51.781641625 +0530
-+++ tiff-4.0.7/libtiff/tif_jpeg.c	2017-04-24 18:05:59.777778815 +0530
-@@ -1626,6 +1626,13 @@
- 	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
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7596.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7596.patch
deleted file mode 100644
index 1945c3d..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7596.patch
+++ /dev/null
@@ -1,308 +0,0 @@
-From 3144e57770c1e4d26520d8abee750f8ac8b75490 Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-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
-
-Upstream-Status: Backport
-
-CVE: CVE-2017-7596
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
-
-Index: tiff-4.0.7/ChangeLog
-===================================================================
---- tiff-4.0.7.orig/ChangeLog	2017-04-25 15:53:40.294592812 +0530
-+++ tiff-4.0.7/ChangeLog	2017-04-25 16:02:03.238600641 +0530
-@@ -6,6 +6,16 @@
- 	Patch by Nicolás Peña.
- 	Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2659
- 
-+2017-01-11 Even Rouault <even.rouault at spatialys.com>
-+
-+	* libtiff/tif_dir.c, tif_dirread.c, tif_dirwrite.c: implement various clampings
-+	of double to other data types to avoid undefined behaviour if the output range
-+	isn't big enough to hold the input value.
-+	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
-+
- 2017-01-11 Even Rouault <even.rouault at spatialys.com>
- 
- 	* libtiff/tif_jpeg.c: avoid integer division by zero in
-Index: tiff-4.0.7/libtiff/tif_dir.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_dir.c	2016-10-30 04:33:18.856598072 +0530
-+++ tiff-4.0.7/libtiff/tif_dir.c	2017-04-25 16:02:03.238600641 +0530
-@@ -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 @@
- 	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 @@
-         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 @@
- 		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);
-Index: tiff-4.0.7/libtiff/tif_dirread.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_dirread.c	2017-04-25 15:53:40.134592810 +0530
-+++ tiff-4.0.7/libtiff/tif_dirread.c	2017-04-25 16:02:03.242600641 +0530
-@@ -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 @@
- 				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;
- 	}
-Index: tiff-4.0.7/libtiff/tif_dirwrite.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_dirwrite.c	2016-10-30 04:33:18.876854501 +0530
-+++ tiff-4.0.7/libtiff/tif_dirwrite.c	2017-04-25 16:07:48.670606018 +0530
-@@ -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 @@
- 	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 @@
- 			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 @@
- 			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 @@
- 			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;
-@@ -2094,15 +2158,25 @@
- 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 != 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;
-@@ -2143,7 +2217,7 @@
- 	}
- 	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;
-@@ -2153,7 +2227,8 @@
- 			nb[0]=(uint32)(*na);
- 			nb[1]=1;
- 		}
--		else if (*na<1.0)
-+		else if (*na >= 0 && *na <= (float)0xFFFFFFFFU &&
-+                         *na==(float)(uint32)(*na))
- 		{
- 			nb[0]=(uint32)((double)(*na)*0xFFFFFFFF);
- 			nb[1]=0xFFFFFFFF;
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7598.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7598.patch
deleted file mode 100644
index 6d082bb..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7598.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-From 3cfd62d77c2a7e147a05bd678524c345fa9c2bb8 Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-Date: Wed, 11 Jan 2017 13:28:01 +0000
-Subject: [PATCH] * libtiff/tif_dirread.c: avoid division by floating point 0
- in TIFFReadDirEntryCheckedRational() and TIFFReadDirEntryCheckedSrational(),
- and return 0 in that case (instead of infinity as before presumably)
- Apparently some sanitizers do not like those divisions by zero. Fixes
- http://bugzilla.maptools.org/show_bug.cgi?id=2644
-
-Upstream-Status: Backport
-
-CVE: CVE-2017-7598
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
-Index: tiff-4.0.7/ChangeLog
-===================================================================
---- tiff-4.0.7.orig/ChangeLog	2017-04-25 16:14:59.858612730 +0530
-+++ tiff-4.0.7/ChangeLog	2017-04-25 18:11:36.048107127 +0530
-@@ -1,3 +1,4 @@
-+
- 2017-01-12 Even Rouault <even.rouault at spatialys.com>
- 
- 	* libtiff/tif_ojpeg.c: fix leak in OJPEGReadHeaderInfoSecTablesQTable,
-@@ -8,6 +9,14 @@
- 
- 2017-01-11 Even Rouault <even.rouault at spatialys.com>
- 
-+	* libtiff/tif_dirread.c: avoid division by floating point 0 in
-+	TIFFReadDirEntryCheckedRational() and TIFFReadDirEntryCheckedSrational(),
-+	and return 0 in that case (instead of infinity as before presumably)
-+	Apparently some sanitizers do not like those divisions by zero.
-+	Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2644
-+
-+2017-01-11 Even Rouault <even.rouault at spatialys.com>
-+
- 	* libtiff/tif_dir.c, tif_dirread.c, tif_dirwrite.c: implement various clampings
- 	of double to other data types to avoid undefined behaviour if the output range
- 	isn't big enough to hold the input value.
-Index: tiff-4.0.7/libtiff/tif_dirread.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_dirread.c	2017-04-25 16:14:59.858612730 +0530
-+++ tiff-4.0.7/libtiff/tif_dirread.c	2017-04-25 18:16:21.836111576 +0530
-@@ -2880,7 +2880,10 @@
- 		m.l = direntry->tdir_offset.toff_long8;
- 	if (tif->tif_flags&TIFF_SWAB)
- 		TIFFSwabArrayOfLong(m.i,2);
--	if (m.i[0]==0)
-+        /* Not completely sure what we should do when m.i[1]==0, but some */
-+        /* sanitizers do not like division by 0.0: */
-+        /* http://bugzilla.maptools.org/show_bug.cgi?id=2644 */
-+	if (m.i[0]==0 || m.i[1]==0)
- 		*value=0.0;
- 	else
- 		*value=(double)m.i[0]/(double)m.i[1];
-@@ -2908,7 +2911,10 @@
- 		m.l=direntry->tdir_offset.toff_long8;
- 	if (tif->tif_flags&TIFF_SWAB)
- 		TIFFSwabArrayOfLong(m.i,2);
--	if ((int32)m.i[0]==0)
-+        /* Not completely sure what we should do when m.i[1]==0, but some */
-+        /* sanitizers do not like division by 0.0: */
-+        /* http://bugzilla.maptools.org/show_bug.cgi?id=2644 */
-+	if ((int32)m.i[0]==0 || m.i[1]==0)
- 		*value=0.0;
- 	else
- 		*value=(double)((int32)m.i[0])/(double)m.i[1];
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7601.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7601.patch
deleted file mode 100644
index 1b3c6c8..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7601.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-From 0a76a8c765c7b8327c59646284fa78c3c27e5490 Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-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
-
-Upstream-Status: Backport
-
-CVE: CVE-2017-7601
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
-Index: tiff-4.0.7/ChangeLog
-===================================================================
---- tiff-4.0.7.orig/ChangeLog	2017-04-25 18:21:32.856116417 +0530
-+++ tiff-4.0.7/ChangeLog	2017-04-25 18:35:31.904129477 +0530
-@@ -1,4 +1,3 @@
--
- 2017-01-12 Even Rouault <even.rouault at spatialys.com>
- 
- 	* libtiff/tif_ojpeg.c: fix leak in OJPEGReadHeaderInfoSecTablesQTable,
-@@ -9,6 +8,12 @@
- 
- 2017-01-11 Even Rouault <even.rouault at spatialys.com>
- 
-+	* 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
-+
-+2017-01-11 Even Rouault <even.rouault at spatialys.com>
-+
- 	* libtiff/tif_dirread.c: avoid division by floating point 0 in
- 	TIFFReadDirEntryCheckedRational() and TIFFReadDirEntryCheckedSrational(),
- 	and return 0 in that case (instead of infinity as before presumably)
-Index: tiff-4.0.7/libtiff/tif_jpeg.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_jpeg.c	2017-04-25 18:21:32.744116415 +0530
-+++ tiff-4.0.7/libtiff/tif_jpeg.c	2017-04-25 18:38:02.200131817 +0530
-@@ -1632,7 +1632,13 @@
-                                    "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
- 		 * default value is inappropriate for YCbCr.  Fill in the
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7602.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7602.patch
deleted file mode 100644
index 9ed97e2..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-7602.patch
+++ /dev/null
@@ -1,69 +0,0 @@
-From 66e7bd59520996740e4df5495a830b42fae48bc4 Mon Sep 17 00:00:00 2001
-From: erouault <erouault>
-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
-
-Upstream-Status: Backport
-
-CVE: CVE-2017-7602
-Signed-off-by: Rajkumar Veer <rveer@mvista.com>
-
-Index: tiff-4.0.7/ChangeLog
-===================================================================
---- tiff-4.0.7.orig/ChangeLog	2017-04-25 18:42:07.656135638 +0530
-+++ tiff-4.0.7/ChangeLog	2017-04-25 18:54:36.812147299 +0530
-@@ -8,6 +8,12 @@
- 
- 2017-01-11 Even Rouault <even.rouault at spatialys.com>
- 
-+	* 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
-+
-+2017-01-11 Even Rouault <even.rouault at spatialys.com>
-+
- 	* 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
-Index: tiff-4.0.7/libtiff/tif_read.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_read.c	2017-04-25 18:42:07.132135629 +0530
-+++ tiff-4.0.7/libtiff/tif_read.c	2017-04-25 18:58:25.272150855 +0530
-@@ -420,16 +420,26 @@
- 			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,
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-9147.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-9147.patch
index 94f3390..3392285 100644
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-9147.patch
+++ b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-9147.patch
@@ -32,38 +32,38 @@
  libtiff/tif_dirread.c |   4 ++
  4 files changed, 128 insertions(+)
 
-Index: tiff-4.0.7/ChangeLog
-===================================================================
---- tiff-4.0.7.orig/ChangeLog
-+++ tiff-4.0.7/ChangeLog
+diff --git a/ChangeLog b/ChangeLog
+index ee8d9d0..5739292 100644
+--- a/ChangeLog
++++ b/ChangeLog
 @@ -1,3 +1,23 @@
 +2017-06-01  Even Rouault <even.rouault at spatialys.com>
 +
-+       * libtiff/tif_dirinfo.c, tif_dirread.c: add _TIFFCheckFieldIsValidForCodec(),
-+       and use it in TIFFReadDirectory() so as to ignore fields whose tag is a
-+       codec-specified tag but this codec is not enabled. This avoids TIFFGetField()
-+       to behave differently depending on whether the codec is enabled or not, and
-+       thus can avoid stack based buffer overflows in a number of TIFF utilities
-+       such as tiffsplit, tiffcmp, thumbnail, etc.
-+       Patch derived from 0063-Handle-properly-CODEC-specific-tags.patch
-+       (http://bugzilla.maptools.org/show_bug.cgi?id=2580) by Raphaël Hertzog.
-+       Fixes:
-+       http://bugzilla.maptools.org/show_bug.cgi?id=2580
-+       http://bugzilla.maptools.org/show_bug.cgi?id=2693
-+       http://bugzilla.maptools.org/show_bug.cgi?id=2625 (CVE-2016-10095)
-+       http://bugzilla.maptools.org/show_bug.cgi?id=2564 (CVE-2015-7554)
-+       http://bugzilla.maptools.org/show_bug.cgi?id=2561 (CVE-2016-5318)
-+       http://bugzilla.maptools.org/show_bug.cgi?id=2499 (CVE-2014-8128)
-+       http://bugzilla.maptools.org/show_bug.cgi?id=2441
-+       http://bugzilla.maptools.org/show_bug.cgi?id=2433
++	* libtiff/tif_dirinfo.c, tif_dirread.c: add _TIFFCheckFieldIsValidForCodec(),
++	and use it in TIFFReadDirectory() so as to ignore fields whose tag is a
++	codec-specified tag but this codec is not enabled. This avoids TIFFGetField()
++	to behave differently depending on whether the codec is enabled or not, and
++	thus can avoid stack based buffer overflows in a number of TIFF utilities
++	such as tiffsplit, tiffcmp, thumbnail, etc.
++	Patch derived from 0063-Handle-properly-CODEC-specific-tags.patch
++	(http://bugzilla.maptools.org/show_bug.cgi?id=2580) by Raphaël Hertzog.
++	Fixes:
++	http://bugzilla.maptools.org/show_bug.cgi?id=2580
++	http://bugzilla.maptools.org/show_bug.cgi?id=2693
++	http://bugzilla.maptools.org/show_bug.cgi?id=2625 (CVE-2016-10095)
++	http://bugzilla.maptools.org/show_bug.cgi?id=2564 (CVE-2015-7554)
++	http://bugzilla.maptools.org/show_bug.cgi?id=2561 (CVE-2016-5318)
++	http://bugzilla.maptools.org/show_bug.cgi?id=2499 (CVE-2014-8128)
++	http://bugzilla.maptools.org/show_bug.cgi?id=2441
++	http://bugzilla.maptools.org/show_bug.cgi?id=2433
 +
- 2017-01-11 Even Rouault <even.rouault at spatialys.com>
+ 2017-05-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
  
- 	* tools/tiffcp.c: error out cleanly in cpContig2SeparateByRow and
-Index: tiff-4.0.7/libtiff/tif_dir.h
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_dir.h
-+++ tiff-4.0.7/libtiff/tif_dir.h
+ 	* configure.ac: libtiff 4.0.8 released.
+diff --git a/libtiff/tif_dir.h b/libtiff/tif_dir.h
+index e12b44b..5206be4 100644
+--- a/libtiff/tif_dir.h
++++ b/libtiff/tif_dir.h
 @@ -291,6 +291,7 @@ struct _TIFFField {
  extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32);
  extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32, TIFFDataType);
@@ -72,11 +72,11 @@
  
  #if defined(__cplusplus)
  }
-Index: tiff-4.0.7/libtiff/tif_dirinfo.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_dirinfo.c
-+++ tiff-4.0.7/libtiff/tif_dirinfo.c
-@@ -956,6 +956,109 @@ TIFFMergeFieldInfo(TIFF* tif, const TIFF
+diff --git a/libtiff/tif_dirinfo.c b/libtiff/tif_dirinfo.c
+index 0c8ef42..97c0df0 100644
+--- a/libtiff/tif_dirinfo.c
++++ b/libtiff/tif_dirinfo.c
+@@ -956,6 +956,109 @@ TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n)
  	return 0;
  }
  
@@ -186,11 +186,11 @@
  /* vim: set ts=8 sts=8 sw=8 noet: */
  
  /*
-Index: tiff-4.0.7/libtiff/tif_dirread.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_dirread.c
-+++ tiff-4.0.7/libtiff/tif_dirread.c
-@@ -3566,6 +3566,10 @@ TIFFReadDirectory(TIFF* tif)
+diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
+index 1d4f0b9..f1dc3d7 100644
+--- a/libtiff/tif_dirread.c
++++ b/libtiff/tif_dirread.c
+@@ -3580,6 +3580,10 @@ TIFFReadDirectory(TIFF* tif)
  							goto bad;
  						dp->tdir_tag=IGNORE;
  						break;
@@ -201,3 +201,6 @@
  				}
  			}
  		}
+-- 
+2.7.4
+
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-9936.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-9936.patch
index 204949b..fc99363 100644
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-9936.patch
+++ b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/CVE-2017-9936.patch
@@ -18,10 +18,10 @@
  libtiff/tif_jbig.c | 1 +
  2 files changed, 7 insertions(+)
 
-Index: tiff-4.0.7/ChangeLog
-===================================================================
---- tiff-4.0.7.orig/ChangeLog
-+++ tiff-4.0.7/ChangeLog
+diff --git a/ChangeLog b/ChangeLog
+index 5739292..0240f0b 100644
+--- a/ChangeLog
++++ b/ChangeLog
 @@ -1,3 +1,9 @@
 +2017-06-26  Even Rouault <even.rouault at spatialys.com>
 +
@@ -31,12 +31,12 @@
 +
  2017-06-01  Even Rouault <even.rouault at spatialys.com>
  
-        * libtiff/tif_dirinfo.c, tif_dirread.c: add _TIFFCheckFieldIsValidForCodec(),
-Index: tiff-4.0.7/libtiff/tif_jbig.c
-===================================================================
---- tiff-4.0.7.orig/libtiff/tif_jbig.c
-+++ tiff-4.0.7/libtiff/tif_jbig.c
-@@ -94,6 +94,7 @@ static int JBIGDecode(TIFF* tif, uint8*
+ 	* libtiff/tif_dirinfo.c, tif_dirread.c: add _TIFFCheckFieldIsValidForCodec(),
+diff --git a/libtiff/tif_jbig.c b/libtiff/tif_jbig.c
+index 5f5f75e..c75f31d 100644
+--- a/libtiff/tif_jbig.c
++++ b/libtiff/tif_jbig.c
+@@ -94,6 +94,7 @@ static int JBIGDecode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s)
  			     jbg_strerror(decodeStatus)
  #endif
  			     );
@@ -44,3 +44,6 @@
  		return 0;
  	}
  
+-- 
+2.7.4
+
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2017-5225.patch b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2017-5225.patch
deleted file mode 100644
index 3263353..0000000
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2017-5225.patch
+++ /dev/null
@@ -1,92 +0,0 @@
-From a24df1e93833dfeaa69bf4d510518dc4684db64d Mon Sep 17 00:00:00 2001
-From: Li Zhou <li.zhou@windriver.com>
-Date: Wed, 25 Jan 2017 17:07:21 +0800
-Subject: [PATCH] libtiff: fix CVE-2017-5225
-
-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
-
-Upstream-Status: Backport
-CVE: CVE-2017-5225
-Signed-off-by: Li Zhou <li.zhou@windriver.com>
----
- ChangeLog      |  7 +++++++
- tools/tiffcp.c | 24 ++++++++++++++++++++++--
- 2 files changed, 29 insertions(+), 2 deletions(-)
-
-diff --git a/ChangeLog b/ChangeLog
-index 9b9d397..7e82795 100644
---- a/ChangeLog
-+++ b/ChangeLog
-@@ -1,3 +1,10 @@
-+2017-01-11 Even Rouault <even.rouault at spatialys.com>
-+
-+	* 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
-+
- 2016-11-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
- 
- 	* libtiff 4.0.7 released.
-diff --git a/tools/tiffcp.c b/tools/tiffcp.c
-index 338a3d1..2e84577 100644
---- a/tools/tiffcp.c
-+++ b/tools/tiffcp.c
-@@ -592,7 +592,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;
-@@ -1068,6 +1068,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);
-@@ -1121,6 +1131,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);
-@@ -1763,7 +1783,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",
--- 
-1.9.1
-
diff --git a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/tiff_4.0.7.bb b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/tiff_4.0.8.bb
similarity index 68%
rename from import-layers/yocto-poky/meta/recipes-multimedia/libtiff/tiff_4.0.7.bb
rename to import-layers/yocto-poky/meta/recipes-multimedia/libtiff/tiff_4.0.8.bb
index 866e852..cb91baa 100644
--- a/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/tiff_4.0.7.bb
+++ b/import-layers/yocto-poky/meta/recipes-multimedia/libtiff/tiff_4.0.8.bb
@@ -6,31 +6,16 @@
 
 SRC_URI = "http://download.osgeo.org/libtiff/tiff-${PV}.tar.gz \
            file://libtool2.patch \
-           file://libtiff-CVE-2017-5225.patch \
            file://CVE-2017-9147.patch \
            file://CVE-2017-9936.patch \
            file://CVE-2017-10688.patch \
            file://CVE-2017-11335.patch \
-           file://CVE-2016-10271.patch \
-           file://CVE-2016-10093.patch \
-           file://CVE-2016-10268.patch \
-           file://CVE-2016-10266.patch \
-           file://CVE-2016-10267.patch \
-           file://CVE-2016-10269.patch \
-           file://CVE-2016-10270.patch \
-           file://CVE-2017-7592.patch \
-           file://CVE-2017-7594-p1.patch \
-           file://CVE-2017-7594-p2.patch \
-           file://CVE-2017-7595.patch \
-           file://CVE-2017-7596.patch \
-           file://CVE-2017-7598.patch \
-           file://CVE-2017-7601.patch \
-           file://CVE-2017-7602.patch \
-           file://CVE-2017-7593.patch \
-        "
+           file://CVE-2017-13726.patch \
+           file://CVE-2017-13727.patch \
+          "
 
-SRC_URI[md5sum] = "77ae928d2c6b7fb46a21c3a29325157b"
-SRC_URI[sha256sum] = "9f43a2cfb9589e5cecaa66e16bf87f814c945f22df7ba600d63aac4632c4f019"
+SRC_URI[md5sum] = "2a7d1c1318416ddf36d5f6fa4600069b"
+SRC_URI[sha256sum] = "59d7a5a8ccd92059913f246877db95a2918e6c04fb9d43fd74e5c3390dac2910"
 
 # exclude betas
 UPSTREAM_CHECK_REGEX = "tiff-(?P<pver>\d+(\.\d+)+).tar"