gnu: gd: Fix CVE-2016-7568.

* gnu/packages/patches/gd-CVE-2016-7568.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/gd.scm (gd)[source]: Use it.
This commit is contained in:
Leo Famulari 2016-09-29 11:32:34 -04:00
parent 43f7af428e
commit 917de2511b
No known key found for this signature in database
GPG key ID: 2646FA30BACA7F08
3 changed files with 47 additions and 1 deletions

View file

@ -529,6 +529,7 @@ dist_patch_DATA = \
%D%/packages/patches/gcc-cross-environment-variables.patch \
%D%/packages/patches/gcc-libvtv-runpath.patch \
%D%/packages/patches/gcc-5.0-libvtv-runpath.patch \
%D%/packages/patches/gd-CVE-2016-7568.patch \
%D%/packages/patches/gd-fix-gd2-read-test.patch \
%D%/packages/patches/gd-fix-tests-on-i686.patch \
%D%/packages/patches/gegl-CVE-2012-4433.patch \

View file

@ -50,7 +50,8 @@ (define-public gd
(sha256
(base32
"0g3xz8jpz1pl2zzmssglrpa9nxiaa7rmcmvgpbrjz8k9cyynqsvl"))
(patches (search-patches "gd-fix-gd2-read-test.patch"
(patches (search-patches "gd-CVE-2016-7568.patch"
"gd-fix-gd2-read-test.patch"
"gd-fix-tests-on-i686.patch"))))
(build-system gnu-build-system)
(native-inputs

View file

@ -0,0 +1,44 @@
Fix CVE-2016-7568 (integer overflow in gdImageWebpCtx()):
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-7568
Patch copied from upstream source repository:
https://github.com/libgd/libgd/commit/2806adfdc27a94d333199345394d7c302952b95f
From 2806adfdc27a94d333199345394d7c302952b95f Mon Sep 17 00:00:00 2001
From: trylab <trylab@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.
---
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.10.0