!27 [sync] PR-25: fix CVE-2021-40145
From: @openeuler-sync-bot Reviewed-by: @t_feng Signed-off-by: @t_feng
This commit is contained in:
commit
060ea20931
77
backport-CVE-2021-40145.patch
Normal file
77
backport-CVE-2021-40145.patch
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
From e95059590fadaabd9aadc0c0489804d75a3c5d52 Mon Sep 17 00:00:00 2001
|
||||||
|
From: maryam ebrahimzadeh <maryam.ebr@student.sharif.edu>
|
||||||
|
Date: Mon, 19 Jul 2021 18:52:50 +0430
|
||||||
|
Subject: [PATCH 1/3] gdImageGd2Ptr memory leak
|
||||||
|
|
||||||
|
Conflict:NA
|
||||||
|
Reference:https://github.com/libgd/libgd/commit/c5fd25ce0e48fd5618a972ca9f5e28d6d62006af
|
||||||
|
---
|
||||||
|
src/gd_gd2.c | 18 +++++++++++++++---
|
||||||
|
1 file changed, 15 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/gd_gd2.c b/src/gd_gd2.c
|
||||||
|
index 760e85b..0b7e624 100644
|
||||||
|
--- a/src/gd_gd2.c
|
||||||
|
+++ b/src/gd_gd2.c
|
||||||
|
@@ -910,9 +910,11 @@ _gd2PutHeader (gdImagePtr im, gdIOCtx * out, int cs, int fmt, int cx, int cy)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void
|
||||||
|
+/* returns 0 on success, 1 on failure */
|
||||||
|
+static int
|
||||||
|
_gdImageGd2 (gdImagePtr im, gdIOCtx * out, int cs, int fmt)
|
||||||
|
{
|
||||||
|
+ int ret = 0;
|
||||||
|
int ncx, ncy, cx, cy;
|
||||||
|
int x, y, ylo, yhi, xlo, xhi;
|
||||||
|
int chunkLen;
|
||||||
|
@@ -974,10 +976,12 @@ _gdImageGd2 (gdImagePtr im, gdIOCtx * out, int cs, int fmt)
|
||||||
|
/* */
|
||||||
|
chunkData = gdCalloc (cs * bytesPerPixel * cs, 1);
|
||||||
|
if (!chunkData) {
|
||||||
|
+ ret = 1;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
compData = gdCalloc (compMax, 1);
|
||||||
|
if (!compData) {
|
||||||
|
+ ret = 1;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -992,6 +996,7 @@ _gdImageGd2 (gdImagePtr im, gdIOCtx * out, int cs, int fmt)
|
||||||
|
|
||||||
|
chunkIdx = gdCalloc (idxSize * sizeof (t_chunk_info), 1);
|
||||||
|
if (!chunkIdx) {
|
||||||
|
+ ret = 1;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@@ -1106,6 +1111,8 @@ fail:
|
||||||
|
gdFree (chunkIdx);
|
||||||
|
}
|
||||||
|
GD2_DBG (printf ("Done\n"));
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1128,8 +1135,13 @@ BGD_DECLARE(void *) gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size)
|
||||||
|
void *rv;
|
||||||
|
gdIOCtx *out = gdNewDynamicCtx (2048, NULL);
|
||||||
|
if (out == NULL) return NULL;
|
||||||
|
- _gdImageGd2 (im, out, cs, fmt);
|
||||||
|
- rv = gdDPExtractData (out, size);
|
||||||
|
+
|
||||||
|
+ if (_gdImageGd2(im, out, cs, fmt)) {
|
||||||
|
+ rv = NULL;
|
||||||
|
+ } else {
|
||||||
|
+ rv = gdDPExtractData(out, size);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
out->gd_free (out);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
6
gd.spec
6
gd.spec
@ -1,6 +1,6 @@
|
|||||||
Name: gd
|
Name: gd
|
||||||
Version: 2.3.2
|
Version: 2.3.2
|
||||||
Release: 1
|
Release: 2
|
||||||
Summary: A graphics library for quick creation of PNG or JPEG images
|
Summary: A graphics library for quick creation of PNG or JPEG images
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: http://libgd.github.io/
|
URL: http://libgd.github.io/
|
||||||
@ -11,6 +11,7 @@ Source1: https://raw.githubusercontent.com/libgd/libgd/gd-%{version}/conf
|
|||||||
|
|
||||||
Patch6000: backport-CVE-2021-38115.patch
|
Patch6000: backport-CVE-2021-38115.patch
|
||||||
Patch6001: backport-CVE-2021-40812.patch
|
Patch6001: backport-CVE-2021-40812.patch
|
||||||
|
Patch6002: backport-CVE-2021-40145.patch
|
||||||
|
|
||||||
BuildRequires: freetype-devel fontconfig-devel gettext-devel libjpeg-devel libpng-devel libtiff-devel libwebp-devel
|
BuildRequires: freetype-devel fontconfig-devel gettext-devel libjpeg-devel libpng-devel libtiff-devel libwebp-devel
|
||||||
BuildRequires: libX11-devel libXpm-devel zlib-devel pkgconfig libtool perl-interpreter perl-generators liberation-sans-fonts
|
BuildRequires: libX11-devel libXpm-devel zlib-devel pkgconfig libtool perl-interpreter perl-generators liberation-sans-fonts
|
||||||
@ -110,6 +111,9 @@ grep %{version} $RPM_BUILD_ROOT%{_libdir}/pkgconfig/gdlib.pc
|
|||||||
%exclude %{_libdir}/libgd.a
|
%exclude %{_libdir}/libgd.a
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Apr 08 2022 dongyuzhen <dongyuzhen@h-partners.com> - 2.3.2-2
|
||||||
|
- fix CVE-2021-40145
|
||||||
|
|
||||||
* Sat Nov 20 2021 hanhui<hanhui15@huawei.com> - 2.3.2-1
|
* Sat Nov 20 2021 hanhui<hanhui15@huawei.com> - 2.3.2-1
|
||||||
- DESC:update to 2.3.2
|
- DESC:update to 2.3.2
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user