gd: Security Advisory CVE-2016-7568
PATCH 1/1 gd: Security Advisory CVE-2016-7568
Backport patch to fix CVE-2016-7568 from gd upstream:
https://github.com/libgd/libgd/commit/2806adfdc27a94d333199345394d7c302952b95f
--- ...01-Fix-integer-overflow-in-gdImageWebpCtx.patch | 41 ++++++++++++++++++++++ meta-oe/recipes-support/gd/gd_2.2.3.bb | 1 + 2 files changed, 42 insertions(+) create mode 100644 meta-oe/recipes-support/gd/gd/0001-Fix-integer-overflow-in-gdImageWebpCtx.patch
meta-oe/recipes-support/gd/gd/0001-Fix-integer-overflow-in-gdImageWebpCtx.patch new file +41 -0
@@ -0,0 +1,41 @@ +From 2806adfdc27a94d333199345394d7c302952b95f Mon Sep 17 00:00:00 2001 +From: trylab <[email protected]> +Date: Tue, 6 Sep 2016 18:35:32 +0800 +Subject: [PATCH] Fix integer overflow in gdImageWebpCtx + +Integer overflow can be happened in expression gdImageSX(im) * 4 * +gdImageSY(im). It could lead to heap buffer overflow in the following +code. This issue has been reported to the PHP Bug Tracking System. The +proof-of-concept file will be supplied some days later. This issue was +discovered by Ke Liu of Tencent's Xuanwu LAB. + +Upstream-Status: Backport + +CVE-2016-7568 + +--- + src/gd_webp.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/gd_webp.c b/src/gd_webp.c +index 8eb4dee..9886399 100644 +--- a/src/gd_webp.c ++++ b/src/gd_webp.c +@@ -199,6 +199,14 @@ BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality) + quality = 80; + } + ++ if (overflow2(gdImageSX(im), 4)) { ++ return; ++ } ++ ++ if (overflow2(gdImageSX(im) * 4, gdImageSY(im))) { ++ return; ++ } ++ + argb = (uint8_t *)gdMalloc(gdImageSX(im) * 4 * gdImageSY(im)); + if (!argb) { + return; +-- +2.9.3 +
meta-oe/recipes-support/gd/gd_2.2.3.bb +1 -0
@@ -15,6 +15,7 @@ DEPENDS = "freetype libpng jpeg zlib tiff" SRC_URI = "git://github.com/libgd/libgd.git;branch=GD-2.2 \ file://fix-gcc-unused-functions.patch \ file://disable-jpeg_read-test.patch \ + file://0001-Fix-integer-overflow-in-gdImageWebpCtx.patch \ " SRCREV = "46ceef5970bf3a847ff61d1bdde7501d66c11d0c"
Signature · 1 line
2.7.4
Quoted 4 lines · Dengke Du
Backport patch to fix CVE-2016-7568 from gd upstream:
https://github.com/libgd/libgd/commit/2806adfdc27a94d333199345394d7c302952b95f
Doesn't apply, always rebase on latest master before sending (gd was last updated months ago).
OE @ ~/meta-openembedded $ pwam 133109
2016-10-21 18:39:13 URL:https://patchwork.openembedded.org/patch/133109/mbox/ [2947] -> "pw-am-133109.patch" [1] Applying: gd: Security Advisory CVE-2016-7568 .git/rebase-apply/patch:37: space before tab in indent. quality = 80; .git/rebase-apply/patch:38: space before tab in indent. }
.git/rebase-apply/patch:39: trailing whitespace.
.git/rebase-apply/patch:48: space before tab in indent.
argb = (uint8_t *)gdMalloc(gdImageSX(im) * 4 * gdImageSY(im));
.git/rebase-apply/patch:49: space before tab in indent.
if (!argb) {error: patch failed: meta-oe/recipes-support/gd/gd_2.2.3.bb:15
error: meta-oe/recipes-support/gd/gd_2.2.3.bb: patch does not apply
Patch failed at 0001 gd: Security Advisory CVE-2016-7568
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
OE @ ~/meta-openembedded $ patch -p1 < pw-am-133109.patch
patching file meta-oe/recipes-support/gd/gd/0001-Fix-integer-overflow-in-gdImageWebpCtx.patch patching file meta-oe/recipes-support/gd/gd_2.2.3.bb
Hunk #1 FAILED at 15.
1 out of 1 hunk FAILED -- saving rejects to file meta-oe/recipes-support/gd/gd_2.2.3.bb.rej OE @ ~/meta-openembedded $ cat meta-oe/recipes-support/gd/gd_2.2.3.bb.rej
recipes-support/gd/gd_2.2.3.bb +1 -0
@@ -15,6 +15,7 @@ DEPENDS = "freetype libpng jpeg zlib tiff" SRC_URI = "git://github.com/libgd/libgd.git;branch=GD-2.2 \ file://fix-gcc-unused-functions.patch \ file://disable-jpeg_read-test.patch \ + file://0001-Fix-integer-overflow-in-gdImageWebpCtx.patch \ " SRCREV = "46ceef5970bf3a847ff61d1bdde7501d66c11d0c"
OE @ ~/meta-openembedded $ git log meta-oe/recipes-support/gd/gd_2.2.3.bb commit 289217bbc3c5c53f486ab5615a6d6196e3c12cf2
Author: Martin Jansa <[email protected]> Date: Thu Aug 18 18:53:48 2016 +0200
meta-oe: fix indentation
* remove tabs which sneaked in since last cleanup
* meta-oe layers are using consistent indentation with 4 spaces, see
http://www.openembedded.org/wiki/Styleguide
Quoted 74 lines
Signed-off-by Dengke Du <[email protected]>--- ...01-Fix-integer-overflow-in-gdImageWebpCtx.patch | 41 ++++++++++++++++++++++ meta-oe/recipes-support/gd/gd_2.2.3.bb | 1 + 2 files changed, 42 insertions(+) create mode 100644 meta-oe/recipes-support/gd/gd/0001-Fix-integer-overflow-in-gdImageWebpCtx.patchmeta-oe/recipes-support/gd/gd/0001-Fix-integer-overflow-in-gdImageWebpCtx.patch new file +41
-0@@ -0,0 +1,41 @@ +From 2806adfdc27a94d333199345394d7c302952b95f Mon Sep 17 00:00:00 2001 +From: trylab <[email protected]> +Date: Tue, 6 Sep 2016 18:35:32 +0800 +Subject: [PATCH] Fix integer overflow in gdImageWebpCtx + +Integer overflow can be happened in expression gdImageSX(im) * 4 * +gdImageSY(im). It could lead to heap buffer overflow in the following +code. This issue has been reported to the PHP Bug Tracking System. The +proof-of-concept file will be supplied some days later. This issue was +discovered by Ke Liu of Tencent's Xuanwu LAB. + +Upstream-Status: Backport + +CVE-2016-7568 + +--- + src/gd_webp.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/gd_webp.c b/src/gd_webp.c +index 8eb4dee..9886399 100644 +--- a/src/gd_webp.c ++++ b/src/gd_webp.c +@@ -199,6 +199,14 @@ BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality) + quality = 80; + } + ++ if (overflow2(gdImageSX(im), 4)) { ++ return; ++ } ++ ++ if (overflow2(gdImageSX(im) * 4, gdImageSY(im))) { ++ return; ++ } ++ + argb = (uint8_t *)gdMalloc(gdImageSX(im) * 4 * gdImageSY(im)); + if (!argb) { + return; +-- +2.9.3 +meta-oe/recipes-support/gd/gd_2.2.3.bb +1
-0@@ -15,6 +15,7 @@ DEPENDS = "freetype libpng jpeg zlib tiff" SRC_URI = "git://github.com/libgd/libgd.git;branch=GD-2.2 \ file://fix-gcc-unused-functions.patch \ file://disable-jpeg_read-test.patch \ + file://0001-Fix-integer-overflow-in-gdImageWebpCtx.patch \ " SRCREV = "46ceef5970bf3a847ff61d1bdde7501d66c11d0c"Signature · 7 lines
2.7.4 -- _______________________________________________ Openembedded-devel mailing list [email protected] http://lists.openembedded.org/mailman/listinfo/openembedded-devel
Signature · 1 line
Martin 'JaMa' Jansa jabber: [email protected]