Skip to content

Commit 5b528da

Browse files
CBL-Mariner-Botarchana25-msjslobodzian
authored
[AUTO-CHERRYPICK] [LOW] Patch unzip to fix CVE-2021-4217 - branch main (#13358)
Co-authored-by: Archana Shettigar <v-shettigara@microsoft.com> Co-authored-by: jslobodzian <joslobo@microsoft.com>
1 parent 7635cf1 commit 5b528da

6 files changed

Lines changed: 62 additions & 7 deletions

File tree

SPECS/unzip/CVE-2021-4217.patch

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From 24bfe051b63f7347d06d852a277ceb657be5d1d4 Mon Sep 17 00:00:00 2001
2+
From: archana25-ms <v-shettigara@microsoft.com>
3+
Date: Tue, 25 Mar 2025 18:05:10 +0000
4+
Subject: [PATCH] Address CVE-2021-4217
5+
Upstream Patch Reference: https://bugs.launchpad.net/ubuntu/+source/unzip/+bug/1957077
6+
7+
---
8+
fileio.c | 5 ++++-
9+
process.c | 6 +++++-
10+
2 files changed, 9 insertions(+), 2 deletions(-)
11+
12+
diff --git a/fileio.c b/fileio.c
13+
index 285f7fe..1de95f2 100644
14+
--- a/fileio.c
15+
+++ b/fileio.c
16+
@@ -2303,8 +2303,11 @@ int do_string(__G__ length, option) /* return PK-type error code */
17+
seek_zipf(__G__ G.cur_zipfile_bufstart - G.extra_bytes +
18+
(G.inptr-G.inbuf) + length);
19+
} else {
20+
- if (readbuf(__G__ (char *)G.extra_field, length) == 0)
21+
+ unsigned bytes_read = readbuf(__G__ (char *)G.extra_field, length);
22+
+ if (bytes_read == 0)
23+
return PK_EOF;
24+
+ if (bytes_read != length)
25+
+ return PK_ERR;
26+
/* Looks like here is where extra fields are read */
27+
if (getZip64Data(__G__ G.extra_field, length) != PK_COOL)
28+
{
29+
diff --git a/process.c b/process.c
30+
index 09d54f7..196b912 100644
31+
--- a/process.c
32+
+++ b/process.c
33+
@@ -2055,10 +2055,14 @@ int getUnicodeData(__G__ ef_buf, ef_len)
34+
G.unipath_checksum = makelong(offset + ef_buf);
35+
offset += 4;
36+
37+
+ if (!G.filename_full) {
38+
+ /* Check if we have a unicode extra section but no filename set */
39+
+ return PK_ERR;
40+
+ }
41+
+
42+
/*
43+
* Compute 32-bit crc
44+
*/
45+
-
46+
chksum = crc32(chksum, (uch *)(G.filename_full),
47+
strlen(G.filename_full));
48+
49+
--
50+
2.45.3
51+

SPECS/unzip/unzip.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: Unzip-6.0
22
Name: unzip
33
Version: 6.0
4-
Release: 21%{?dist}
4+
Release: 22%{?dist}
55
License: BSD
66
Vendor: Microsoft Corporation
77
Distribution: Mariner
@@ -24,6 +24,7 @@ Patch12: unzip-zipbomb-manpage.patch
2424
Patch13: CVE-2015-7697.patch
2525
Patch14: CVE-2018-1000035.patch
2626
Patch15: CVE-2022-0529.patch
27+
Patch16: CVE-2021-4217.patch
2728

2829
%description
2930
The UnZip package contains ZIP extraction utilities. These are useful
@@ -58,6 +59,9 @@ ln -sf unzip %{buildroot}%{_bindir}/zipinfo
5859
%{_bindir}/*
5960

6061
%changelog
62+
* Tue Mar 25 2025 Archana Shettigar <v-shettigara@microsoft.com> - 6.0.22
63+
- Fix CVE-2021-4217
64+
6165
* Mon Nov 25 2024 Kavya Sree Kaitepalli <kkaitepalli@microsoft.com> - 6.0.21
6266
- Fix CVE-2022-0529 and CVE-2022-0530
6367

toolkit/resources/manifests/package/pkggen_core_aarch64.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ ca-certificates-tools-2.0.0-19.cm2.noarch.rpm
236236
ca-certificates-base-2.0.0-19.cm2.noarch.rpm
237237
ca-certificates-2.0.0-19.cm2.noarch.rpm
238238
dwz-0.14-2.cm2.aarch64.rpm
239-
unzip-6.0-21.cm2.aarch64.rpm
239+
unzip-6.0-22.cm2.aarch64.rpm
240240
python3-3.9.19-12.cm2.aarch64.rpm
241241
python3-devel-3.9.19-12.cm2.aarch64.rpm
242242
python3-libs-3.9.19-12.cm2.aarch64.rpm

toolkit/resources/manifests/package/pkggen_core_x86_64.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ ca-certificates-tools-2.0.0-19.cm2.noarch.rpm
236236
ca-certificates-base-2.0.0-19.cm2.noarch.rpm
237237
ca-certificates-2.0.0-19.cm2.noarch.rpm
238238
dwz-0.14-2.cm2.x86_64.rpm
239-
unzip-6.0-21.cm2.x86_64.rpm
239+
unzip-6.0-22.cm2.x86_64.rpm
240240
python3-3.9.19-12.cm2.x86_64.rpm
241241
python3-devel-3.9.19-12.cm2.x86_64.rpm
242242
python3-libs-3.9.19-12.cm2.x86_64.rpm

toolkit/resources/manifests/package/toolchain_aarch64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,8 @@ tdnf-plugin-repogpgcheck-3.5.2-4.cm2.aarch64.rpm
570570
tdnf-python-3.5.2-4.cm2.aarch64.rpm
571571
texinfo-6.8-1.cm2.aarch64.rpm
572572
texinfo-debuginfo-6.8-1.cm2.aarch64.rpm
573-
unzip-6.0-21.cm2.aarch64.rpm
574-
unzip-debuginfo-6.0-21.cm2.aarch64.rpm
573+
unzip-6.0-22.cm2.aarch64.rpm
574+
unzip-debuginfo-6.0-22.cm2.aarch64.rpm
575575
util-linux-2.37.4-9.cm2.aarch64.rpm
576576
util-linux-debuginfo-2.37.4-9.cm2.aarch64.rpm
577577
util-linux-devel-2.37.4-9.cm2.aarch64.rpm

toolkit/resources/manifests/package/toolchain_x86_64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ tdnf-plugin-repogpgcheck-3.5.2-4.cm2.x86_64.rpm
576576
tdnf-python-3.5.2-4.cm2.x86_64.rpm
577577
texinfo-6.8-1.cm2.x86_64.rpm
578578
texinfo-debuginfo-6.8-1.cm2.x86_64.rpm
579-
unzip-6.0-21.cm2.x86_64.rpm
580-
unzip-debuginfo-6.0-21.cm2.x86_64.rpm
579+
unzip-6.0-22.cm2.x86_64.rpm
580+
unzip-debuginfo-6.0-22.cm2.x86_64.rpm
581581
util-linux-2.37.4-9.cm2.x86_64.rpm
582582
util-linux-debuginfo-2.37.4-9.cm2.x86_64.rpm
583583
util-linux-devel-2.37.4-9.cm2.x86_64.rpm

0 commit comments

Comments
 (0)