From 99d93ed2452308be79858c0f83b66b6fd380467c Mon Sep 17 00:00:00 2001 From: dongyuzhen Date: Fri, 12 Aug 2022 18:08:34 +0800 Subject: [PATCH] fix CVE-2022-37434 --- backport-0001-CVE-2022-37434.patch | 35 ++++++++++++++++++++++++++++++ backport-0002-CVE-2022-37434.patch | 32 +++++++++++++++++++++++++++ zlib.spec | 9 +++++++- 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 backport-0001-CVE-2022-37434.patch create mode 100644 backport-0002-CVE-2022-37434.patch diff --git a/backport-0001-CVE-2022-37434.patch b/backport-0001-CVE-2022-37434.patch new file mode 100644 index 0000000..59d75a6 --- /dev/null +++ b/backport-0001-CVE-2022-37434.patch @@ -0,0 +1,35 @@ +From eff308af425b67093bab25f80f1ae950166bece1 Mon Sep 17 00:00:00 2001 +From: Mark Adler +Date: Sat, 30 Jul 2022 15:51:11 -0700 +Subject: [PATCH] Fix a bug when getting a gzip header extra field with + inflate(). + +If the extra field was larger than the space the user provided with +inflateGetHeader(), and if multiple calls of inflate() delivered +the extra header data, then there could be a buffer overflow of the +provided space. This commit assures that provided space is not +exceeded. +--- + inflate.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/inflate.c b/inflate.c +index 2a0ac30..95a38f5 100644 +--- a/inflate.c ++++ b/inflate.c +@@ -765,9 +765,10 @@ int flush; + copy = state->length; + if (copy > have) copy = have; + if (copy) { ++ len = state->head->extra_len - state->length; + if (state->head != Z_NULL && +- state->head->extra != Z_NULL) { +- len = state->head->extra_len - state->length; ++ state->head->extra != Z_NULL && ++ len < state->head->extra_max) { + zmemcpy(state->head->extra + len, next, + len + copy > state->head->extra_max ? + state->head->extra_max - len : copy); +-- +2.27.0 + diff --git a/backport-0002-CVE-2022-37434.patch b/backport-0002-CVE-2022-37434.patch new file mode 100644 index 0000000..a115fce --- /dev/null +++ b/backport-0002-CVE-2022-37434.patch @@ -0,0 +1,32 @@ +From 1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d Mon Sep 17 00:00:00 2001 +From: Mark Adler +Date: Mon, 8 Aug 2022 10:50:09 -0700 +Subject: [PATCH] Fix extra field processing bug that dereferences NULL + state->head. + +The recent commit to fix a gzip header extra field processing bug +introduced the new bug fixed here. +--- + inflate.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/inflate.c b/inflate.c +index 95a38f5..9c5934e 100644 +--- a/inflate.c ++++ b/inflate.c +@@ -765,10 +765,10 @@ int flush; + copy = state->length; + if (copy > have) copy = have; + if (copy) { +- len = state->head->extra_len - state->length; + if (state->head != Z_NULL && + state->head->extra != Z_NULL && +- len < state->head->extra_max) { ++ (len = state->head->extra_len - state->length) < ++ state->head->extra_max) { + zmemcpy(state->head->extra + len, next, + len + copy > state->head->extra_max ? + state->head->extra_max - len : copy); +-- +2.27.0 + diff --git a/zlib.spec b/zlib.spec index a53a845..b15603b 100644 --- a/zlib.spec +++ b/zlib.spec @@ -1,6 +1,6 @@ Name: zlib Version: 1.2.11 -Release: 21 +Release: 22 Summary: A lossless data-compression library License: zlib and Boost URL: http://www.zlib.net @@ -20,6 +20,8 @@ Patch5: zlib-1.2.11-SIMD.patch Patch6000: fix-undefined-buffer-detected-by-oss-fuzz.patch Patch6001: backport-0001-CVE-2018-25032.patch Patch6002: backport-0002-CVE-2018-25032.patch +Patch6003: backport-0001-CVE-2022-37434.patch +Patch6004: backport-0002-CVE-2022-37434.patch BuildRequires: automake, autoconf, libtool @@ -74,6 +76,8 @@ This package contains the development-related content related to minizip. %patch6000 -p1 %patch6001 -p1 %patch6002 -p1 +%patch6003 -p1 +%patch6004 -p1 %build export CFLAGS="$RPM_OPT_FLAGS" @@ -131,6 +135,9 @@ make test %{_libdir}/pkgconfig/minizip.pc %changelog +* Fri Aug 12 2022 dongyuzhen - 1.2.11-22 +- fix CVE-2022-37434 + * Tue May 10 2022 tinawei - 1.2.11-21 - Fix patches info for pre -- Gitee