summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2018-08-30 12:54:11 +0200
committerRemi Collet <remi@remirepo.net>2018-08-30 12:54:11 +0200
commitf0d45ca534d0b0f74e82694ee81176fc78299e72 (patch)
tree025827b46ab156d40fe8f428293caa3fbd273af4
parent1b11443e99c3247957ec38cd317c49d497d5a2d7 (diff)
Sync with Fedora
* Thu Aug 30 2018 mskalick@redhat.com - 2.2.5-5 - Check return value in gdImageBmpPtr to avoid double free (CVE-2018-1000222) - Don't mark gdimagegrayscale/basic test as failing
-rw-r--r--gd-2.2.5-gdImageBmpPtr-double-free.patch73
-rw-r--r--gd.spec13
2 files changed, 84 insertions, 2 deletions
diff --git a/gd-2.2.5-gdImageBmpPtr-double-free.patch b/gd-2.2.5-gdImageBmpPtr-double-free.patch
new file mode 100644
index 0000000..80f9712
--- /dev/null
+++ b/gd-2.2.5-gdImageBmpPtr-double-free.patch
@@ -0,0 +1,73 @@
+From ac16bdf2d41724b5a65255d4c28fb0ec46bc42f5 Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier@gentoo.org>
+Date: Sat, 14 Jul 2018 13:54:08 -0400
+Subject: [PATCH] bmp: check return value in gdImageBmpPtr
+
+Closes #447.
+---
+ src/gd_bmp.c | 17 ++++++++++++++---
+ 1 file changed, 14 insertions(+), 3 deletions(-)
+
+diff --git a/src/gd_bmp.c b/src/gd_bmp.c
+index bde0b9d3..78f40d9a 100644
+--- a/src/gd_bmp.c
++++ b/src/gd_bmp.c
+@@ -47,6 +47,8 @@ static int bmp_read_4bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp
+ static int bmp_read_8bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header);
+ static int bmp_read_rle(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info);
+
++static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression);
++
+ #define BMP_DEBUG(s)
+
+ static int gdBMPPutWord(gdIOCtx *out, int w)
+@@ -87,8 +89,10 @@ BGD_DECLARE(void *) gdImageBmpPtr(gdImagePtr im, int *size, int compression)
+ void *rv;
+ gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
+ if (out == NULL) return NULL;
+- gdImageBmpCtx(im, out, compression);
+- rv = gdDPExtractData(out, size);
++ if (!_gdImageBmpCtx(im, out, compression))
++ rv = gdDPExtractData(out, size);
++ else
++ rv = NULL;
+ out->gd_free(out);
+ return rv;
+ }
+@@ -141,6 +145,11 @@ BGD_DECLARE(void) gdImageBmp(gdImagePtr im, FILE *outFile, int compression)
+ compression - whether to apply RLE or not.
+ */
+ BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
++{
++ _gdImageBmpCtx(im, out, compression);
++}
++
++static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
+ {
+ int bitmap_size = 0, info_size, total_size, padding;
+ int i, row, xpos, pixel;
+@@ -148,6 +157,7 @@ BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
+ unsigned char *uncompressed_row = NULL, *uncompressed_row_start = NULL;
+ FILE *tmpfile_for_compression = NULL;
+ gdIOCtxPtr out_original = NULL;
++ int ret = 1;
+
+ /* No compression if its true colour or we don't support seek */
+ if (im->trueColor) {
+@@ -325,6 +335,7 @@ BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
+ out_original = NULL;
+ }
+
++ ret = 0;
+ cleanup:
+ if (tmpfile_for_compression) {
+ #ifdef _WIN32
+@@ -338,7 +349,7 @@ BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
+ if (out_original) {
+ out_original->gd_free(out_original);
+ }
+- return;
++ return ret;
+ }
+
+ static int compress_row(unsigned char *row, int length)
diff --git a/gd.spec b/gd.spec
index e3e6234..a5f6590 100644
--- a/gd.spec
+++ b/gd.spec
@@ -28,7 +28,7 @@ Name: gd
Name: gd-last
%endif
Version: 2.2.5
-Release: 2%{?prever}%{?short}%{?dist}
+Release: 5%{?prever}%{?short}%{?dist}
Group: System Environment/Libraries
License: MIT
URL: http://libgd.github.io/
@@ -43,6 +43,8 @@ Source0: https://github.com/libgd/libgd/releases/download/gd-%{version}/li
Patch1: gd-2.1.0-multilib.patch
# CVE-2018-5711 - https://github.com/libgd/libgd/commit/a11f47475e6443b7f32d21f2271f28f417e2ac04
Patch2: gd-2.2.5-upstream.patch
+# CVE-2018-1000222 - https://github.com/libgd/libgd/commit/ac16bdf2d41724b5a65255d4c28fb0ec46bc42f5
+Patch3: gd-2.2.5-gdImageBmpPtr-double-free.patch
BuildRequires: freetype-devel
BuildRequires: fontconfig-devel
@@ -129,6 +131,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 .upstream
+%patch3 -p1 -b .gdImageBmpPtr-free
: $(perl config/getver.pl)
@@ -180,10 +183,12 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/libgd.a
%check
+%if 0%{?fedora} <= 28 && 0%{?rhel} <= 7
%ifarch %{ix86}
# See https://github.com/libgd/libgd/issues/359
XFAIL_TESTS="gdimagegrayscale/basic $XFAIL_TESTS"
%endif
+%endif
%if 0%{?rhel} > 0 && 0%{?rhel} <= 6
# See https://github.com/libgd/libgd/issues/363
XFAIL_TESTS="freetype/bug00132 $XFAIL_TESTS"
@@ -221,7 +226,11 @@ grep %{version} $RPM_BUILD_ROOT%{_libdir}/pkgconfig/gdlib.pc
%changelog
-* Mon Mar 26 2018 Marek Skalick√Ĺ <mskalick@redhat.com> - 2.2.5-2
+* Thu Aug 30 2018 mskalick@redhat.com - 2.2.5-5
+- Check return value in gdImageBmpPtr to avoid double free (CVE-2018-1000222)
+- Don't mark gdimagegrayscale/basic test as failing
+
+* Mon Mar 26 2018 Marek Skalick√Ĺ <mskalick@redhat.com> - 2.2.5-3
- Fix CVE-2018-5711 - Potential infinite loop in gdImageCreateFromGifCtx
* Wed Aug 30 2017 Remi Collet <remi@fedoraproject.org> - 2.2.5-1