Added and ported the patch to fix the CVE
Change-Id: I229b3d5053bf9ca0e20af450ce5749212a23d637
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/6759
Tested-by: michellew <michellew@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,29 @@ |
| 0 |
+From 23d0a0bc3c0b858e5b491373e59b7c3e5c7d7ed5 Mon Sep 17 00:00:00 2001 |
|
| 1 |
+From: "Christoph M. Becker" <cmbecker69@gmx.de> |
|
| 2 |
+Date: Sun, 30 Dec 2018 13:59:26 +0100 |
|
| 3 |
+Subject: [PATCH] Fix #77270: imagecolormatch Out Of Bounds Write on Heap |
|
| 4 |
+ |
|
| 5 |
+At least some of the image reading functions may return images which |
|
| 6 |
+use color indexes greater than or equal to im->colorsTotal. We cater |
|
| 7 |
+to this by always using a buffer size which is sufficient for |
|
| 8 |
+`gdMaxColors` in `gdImageColorMatch()`. |
|
| 9 |
+--- |
|
| 10 |
+ src/gd_color_match.c | 4 ++-- |
|
| 11 |
+ 1 files changed, 2 insertions(+), 2 deletions(-) |
|
| 12 |
+ |
|
| 13 |
+diff --git a/src/gd_color_match.c b/src/gd_color_match.c |
|
| 14 |
+index f0842b6..a94a841 100755 |
|
| 15 |
+--- a/src/gd_color_match.c |
|
| 16 |
+@@ -31,8 +31,8 @@ BGD_DECLARE(int) gdImageColorMatch (gdImagePtr im1, gdImagePtr im2) |
|
| 17 |
+ return -4; /* At least 1 color must be allocated */ |
|
| 18 |
+ } |
|
| 19 |
+ |
|
| 20 |
+- buf = (unsigned long *)gdMalloc(sizeof(unsigned long) * 5 * im2->colorsTotal); |
|
| 21 |
+- memset (buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal ); |
|
| 22 |
++ buf = (unsigned long *)gdMalloc(sizeof(unsigned long) * 5 * gdMaxColors); |
|
| 23 |
++ memset (buf, 0, sizeof(unsigned long) * 5 * gdMaxColors ); |
|
| 24 |
+ |
|
| 25 |
+ for (x=0; x < im1->sx; x++) {
|
|
| 26 |
+ for( y=0; y<im1->sy; y++ ) {
|
|
| 27 |
+-- |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
Summary: GD is an open source code library for the dynamic creation of images by programmers. |
| 2 | 2 |
Name: libgd |
| 3 | 3 |
Version: 2.2.5 |
| 4 |
-Release: 3%{?dist}
|
|
| 4 |
+Release: 4%{?dist}
|
|
| 5 | 5 |
License: MIT |
| 6 | 6 |
URL: https://libgd.github.io/ |
| 7 | 7 |
Group: System/Libraries |
| ... | ... |
@@ -11,6 +11,7 @@ Source0: https://github.com/libgd/libgd/releases/download/gd-%{version}/%
|
| 11 | 11 |
%define sha1 libgd=b777b005c401b6fa310ccf09eeb29f6c6e17ab2c |
| 12 | 12 |
Patch0: CVE-2018-1000222.patch |
| 13 | 13 |
Patch1: libgd-CVE-2019-6978.patch |
| 14 |
+Patch2: libgd-CVE-2019-6977.patch |
|
| 14 | 15 |
BuildRequires: libjpeg-turbo-devel |
| 15 | 16 |
BuildRequires: libpng-devel |
| 16 | 17 |
BuildRequires: libwebp-devel |
| ... | ... |
@@ -33,6 +34,7 @@ Header & Development files |
| 33 | 33 |
%setup -q |
| 34 | 34 |
%patch0 -p1 |
| 35 | 35 |
%patch1 -p1 |
| 36 |
+%patch2 -p1 |
|
| 36 | 37 |
|
| 37 | 38 |
%build |
| 38 | 39 |
# To use the system installed automake latest version instead of given version in source |
| ... | ... |
@@ -57,6 +59,8 @@ make %{?_smp_mflags} -k check
|
| 57 | 57 |
%{_libdir}/pkgconfig/*
|
| 58 | 58 |
|
| 59 | 59 |
%changelog |
| 60 |
+* Tue Feb 19 2019 Ankit Jain <ankitja@vmware.com> 2.2.5-4 |
|
| 61 |
+- Fix for CVE-2019-6977 |
|
| 60 | 62 |
* Wed Jan 30 2019 Ankit Jain <ankitja@vmware.com> 2.2.5-3 |
| 61 | 63 |
- Fix for CVE-2019-6978 |
| 62 | 64 |
* Fri Nov 02 2018 Ankit Jain <ankitja@vmware.com> 2.2.5-2 |