From 23377414c38bba5f64cc98f2172c62df5e6e863e Mon Sep 17 00:00:00 2001 From: Marek Skalický Date: Dec 05 2016 09:10:05 +0000 Subject: Fix possible overflow in gdImageWebpCtx (CVE-2016-7568) --- diff --git a/gd-2.2.3-overflow-in-gdImageWebpCtx.patch b/gd-2.2.3-overflow-in-gdImageWebpCtx.patch new file mode 100644 index 0000000..fdf522c --- /dev/null +++ b/gd-2.2.3-overflow-in-gdImageWebpCtx.patch @@ -0,0 +1,33 @@ +From 2806adfdc27a94d333199345394d7c302952b95f Mon Sep 17 00:00:00 2001 +From: trylab +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) + quantization = 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; diff --git a/gd.spec b/gd.spec index 49f23dc..2374a49 100644 --- a/gd.spec +++ b/gd.spec @@ -5,7 +5,7 @@ Summary: A graphics library for quick creation of PNG or JPEG images Name: gd Version: 2.2.3 -Release: 2%{?prever}%{?short}%{?dist} +Release: 3%{?prever}%{?short}%{?dist} Group: System Environment/Libraries License: MIT URL: http://libgd.github.io/ @@ -19,6 +19,7 @@ Source0: https://github.com/libgd/libgd/releases/download/gd-%{version}/li Patch1: gd-2.1.0-multilib.patch Patch2: gd-2.2.3-tests.patch +Patch3: gd-2.2.3-overflow-in-gdImageWebpCtx.patch BuildRequires: freetype-devel BuildRequires: fontconfig-devel @@ -78,6 +79,7 @@ files for gd, a graphics library for creating PNG and JPEG graphics. %setup -q -n libgd-%{version}%{?prever:-%{prever}} %patch1 -p1 -b .mlib %patch2 -p1 -b .build +%patch3 -p1 -b .gdImageWebpCtx : $(perl config/getver.pl) @@ -152,6 +154,9 @@ grep %{version} $RPM_BUILD_ROOT%{_libdir}/pkgconfig/gdlib.pc %changelog +* Mon Dec 05 2016 Marek Skalický - 2.2.3-3 +- Fix possible overflow in gdImageWebpCtx (CVE-2016-7568) + * Tue Jul 26 2016 Dan Horák - 2.2.3-2 - apply workaround for rhbz#1359680