From cd0992470f2ddb6786503766a9cd049c6fa14965 Mon Sep 17 00:00:00 2001 From: Lukas Javorsky Date: Tue, 24 Oct 2023 16:22:19 +0000 Subject: [PATCH] Fix for CVE-2023-45853 --- .zlib.metadata | 1 + ...lows-of-zip-header-fields-in-minizip.patch | 39 +++++++++++++++++++ zlib.spec | 10 ++++- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 .zlib.metadata create mode 100644 zlib-1.2.13-Reject-overflows-of-zip-header-fields-in-minizip.patch diff --git a/.zlib.metadata b/.zlib.metadata new file mode 100644 index 0000000..597ffcb --- /dev/null +++ b/.zlib.metadata @@ -0,0 +1 @@ +e1cb0d5c92da8e9a8c2635dfa249c341dfd00322 zlib-1.2.11.tar.xz diff --git a/zlib-1.2.13-Reject-overflows-of-zip-header-fields-in-minizip.patch b/zlib-1.2.13-Reject-overflows-of-zip-header-fields-in-minizip.patch new file mode 100644 index 0000000..35e3073 --- /dev/null +++ b/zlib-1.2.13-Reject-overflows-of-zip-header-fields-in-minizip.patch @@ -0,0 +1,39 @@ +From 73331a6a0481067628f065ffe87bb1d8f787d10c Mon Sep 17 00:00:00 2001 +From: Hans Wennborg +Date: Fri, 18 Aug 2023 11:05:33 +0200 +Subject: [PATCH] Reject overflows of zip header fields in minizip. + +This checks the lengths of the file name, extra field, and comment +that would be put in the zip headers, and rejects them if they are +too long. They are each limited to 65535 bytes in length by the zip +format. This also avoids possible buffer overflows if the provided +fields are too long. +--- + contrib/minizip/zip.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c +index 3d3d4ca..0446109 100644 +--- a/contrib/minizip/zip.c ++++ b/contrib/minizip/zip.c +@@ -1043,6 +1043,17 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c + return ZIP_PARAMERROR; + #endif + ++ // The filename and comment length must fit in 16 bits. ++ if ((filename!=NULL) && (strlen(filename)>0xffff)) ++ return ZIP_PARAMERROR; ++ if ((comment!=NULL) && (strlen(comment)>0xffff)) ++ return ZIP_PARAMERROR; ++ // The extra field length must fit in 16 bits. If the member also requires ++ // a Zip64 extra block, that will also need to fit within that 16-bit ++ // length, but that will be checked for later. ++ if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff)) ++ return ZIP_PARAMERROR; ++ + zi = (zip64_internal*)file; + + if (zi->in_opened_file_inzip == 1) +-- +2.41.0 + diff --git a/zlib.spec b/zlib.spec index dba4101..66c23fe 100644 --- a/zlib.spec +++ b/zlib.spec @@ -2,7 +2,7 @@ Name: zlib Version: 1.2.11 -Release: 40%{?dist} +Release: 41%{?dist} Summary: Compression and decompression library # /contrib/dotzlib/ have Boost license License: zlib and Boost @@ -64,6 +64,9 @@ Patch28: zlib-1.2.11-covscan-issues.patch # Resolves: #2193044 Patch29: zlib-1.2.11-IBM-Z-hw-accelrated-deflate-fix-crash-deflateBound.patch +# Upstream patch: https://github.com/madler/zlib/commit/73331a6a0481067628f065ffe87bb1d8f787d10c +Patch30: zlib-1.2.13-Reject-overflows-of-zip-header-fields-in-minizip.patch + BuildRequires: make BuildRequires: automake, autoconf, libtool @@ -141,6 +144,7 @@ developing applications which use minizip. %patch27 -p1 %patch28 -p1 %patch29 -p1 +%patch30 -p1 iconv -f iso-8859-2 -t utf-8 < ChangeLog > ChangeLog.tmp @@ -218,6 +222,10 @@ find $RPM_BUILD_ROOT -name '*.la' -delete %changelog +* Tue Oct 24 2023 Lukas Javorsky - 1.2.11-40 +- Applied upstream commit 73331a6a0481067628f065ffe87bb1d8f787d10c +- Fixes: CVE-2023-45853 + * Thu May 04 2023 Lukas Javorsky - 1.2.11-40 - Fix the Crash in zlib deflateBound() function on s390x - Resolves: BZ#2193044