[oe] [PATCH] gd: Security Advisory CVE-2016-7568

Martin Jansa martin.jansa at gmail.com
Fri Oct 21 16:41:06 UTC 2016


On Fri, Oct 21, 2016 at 04:19:14PM +0800, Dengke Du wrote:
> 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
--- meta-oe/recipes-support/gd/gd_2.2.3.bb
+++ meta-oe/recipes-support/gd/gd_2.2.3.bb
@@ -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 <Martin.Jansa at gmail.com>
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
    
    Signed-off-by: Martin Jansa <Martin.Jansa at gmail.com>


> Signed-off-by: Dengke Du <dengke.du at windriver.com>
> ---
>  ...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
> 
> diff --git a/meta-oe/recipes-support/gd/gd/0001-Fix-integer-overflow-in-gdImageWebpCtx.patch b/meta-oe/recipes-support/gd/gd/0001-Fix-integer-overflow-in-gdImageWebpCtx.patch
> new file mode 100644
> index 0000000..9967e23
> --- /dev/null
> +++ b/meta-oe/recipes-support/gd/gd/0001-Fix-integer-overflow-in-gdImageWebpCtx.patch
> @@ -0,0 +1,41 @@
> +From 2806adfdc27a94d333199345394d7c302952b95f Mon Sep 17 00:00:00 2001
> +From: trylab <trylab at users.noreply.github.com>
> +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
> +
> diff --git a/meta-oe/recipes-support/gd/gd_2.2.3.bb b/meta-oe/recipes-support/gd/gd_2.2.3.bb
> index 9655e9c..f7d4f44 100644
> --- a/meta-oe/recipes-support/gd/gd_2.2.3.bb
> +++ b/meta-oe/recipes-support/gd/gd_2.2.3.bb
> @@ -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"
> -- 
> 2.7.4
> 
> -- 
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: Digital signature
URL: <http://lists.openembedded.org/pipermail/openembedded-devel/attachments/20161021/41fc5711/attachment-0002.sig>


More information about the Openembedded-devel mailing list