Skip to content

Commit 1f4bce0

Browse files
committed
Patch libarchive for CVE-2024-48615 [High] (#13287)
(cherry picked from commit 239643c)
1 parent 2e6ac12 commit 1f4bce0

6 files changed

Lines changed: 95 additions & 11 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
From 8d57799b49ab165210d34bdc201971e15c013288 Mon Sep 17 00:00:00 2001
2+
From: kavyasree <kkaitepalli@microsoft.com>
3+
Date: Mon, 7 Apr 2025 12:04:21 +0530
4+
Subject: [PATCH] Error handling for each call of __archive_read_ahead
5+
6+
Reference: https://github.com/libarchive/libarchive/commit/565b5aea491671ae33df1ca63697c10d54c00165
7+
---
8+
libarchive/archive_read_support_format_tar.c | 17 +++++++----------
9+
1 file changed, 7 insertions(+), 10 deletions(-)
10+
11+
diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c
12+
index bfdad7f..e654de7 100644
13+
--- a/libarchive/archive_read_support_format_tar.c
14+
+++ b/libarchive/archive_read_support_format_tar.c
15+
@@ -625,8 +625,6 @@ archive_read_format_tar_read_data(struct archive_read *a,
16+
}
17+
18+
*buff = __archive_read_ahead(a, 1, &bytes_read);
19+
- if (bytes_read < 0)
20+
- return (ARCHIVE_FATAL);
21+
if (*buff == NULL) {
22+
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
23+
"Truncated tar archive");
24+
@@ -711,13 +709,11 @@ tar_read_header(struct archive_read *a, struct tar *tar,
25+
26+
/* Read 512-byte header record */
27+
h = __archive_read_ahead(a, 512, &bytes);
28+
- if (bytes < 0)
29+
- return ((int)bytes);
30+
if (bytes == 0) { /* EOF at a block boundary. */
31+
/* Some writers do omit the block of nulls. <sigh> */
32+
return (ARCHIVE_EOF);
33+
}
34+
- if (bytes < 512) { /* Short block at EOF; this is bad. */
35+
+ if (h == NULL) { /* Short block at EOF; this is bad. */
36+
archive_set_error(&a->archive,
37+
ARCHIVE_ERRNO_FILE_FORMAT,
38+
"Truncated tar archive");
39+
@@ -1459,6 +1455,9 @@ read_mac_metadata_blob(struct archive_read *a, struct tar *tar,
40+
*/
41+
data = __archive_read_ahead(a, msize, NULL);
42+
if (data == NULL) {
43+
+ archive_set_error(&a->archive, EINVAL,
44+
+ "Truncated archive"
45+
+ " detected while reading macOS metadata");
46+
*unconsumed = 0;
47+
return (ARCHIVE_FATAL);
48+
}
49+
@@ -2345,9 +2344,7 @@ gnu_sparse_old_read(struct archive_read *a, struct tar *tar,
50+
do {
51+
tar_flush_unconsumed(a, unconsumed);
52+
data = __archive_read_ahead(a, 512, &bytes_read);
53+
- if (bytes_read < 0)
54+
- return (ARCHIVE_FATAL);
55+
- if (bytes_read < 512) {
56+
+ if (data == NULL) {
57+
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
58+
"Truncated tar archive "
59+
"detected while reading sparse file data");
60+
@@ -2755,7 +2752,7 @@ readline(struct archive_read *a, struct tar *tar, const char **start,
61+
tar_flush_unconsumed(a, unconsumed);
62+
63+
t = __archive_read_ahead(a, 1, &bytes_read);
64+
- if (bytes_read <= 0)
65+
+ if (bytes_read <= 0 || t == NULL)
66+
return (ARCHIVE_FATAL);
67+
s = t; /* Start of line? */
68+
p = memchr(t, '\n', bytes_read);
69+
@@ -2796,7 +2793,7 @@ readline(struct archive_read *a, struct tar *tar, const char **start,
70+
}
71+
/* Read some more. */
72+
t = __archive_read_ahead(a, 1, &bytes_read);
73+
- if (bytes_read <= 0)
74+
+ if (bytes_read <= 0 || t == NULL)
75+
return (ARCHIVE_FATAL);
76+
s = t; /* Start of line? */
77+
p = memchr(t, '\n', bytes_read);
78+
--
79+
2.34.1
80+

SPECS/libarchive/libarchive.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: Multi-format archive and compression library
22
Name: libarchive
33
Version: 3.6.1
4-
Release: 5%{?dist}
4+
Release: 6%{?dist}
55
# Certain files have individual licenses. For more details see contents of "COPYING".
66
License: BSD AND Public Domain AND (ASL 2.0 OR CC0 1.0 OR OpenSSL)
77
Vendor: Microsoft Corporation
@@ -15,6 +15,7 @@ Patch2: CVE-2024-20696.patch
1515
Patch3: CVE-2024-48958.patch
1616
Patch4: CVE-2024-48957.patch
1717
Patch5: CVE-2025-25724.patch
18+
Patch6: CVE-2024-48615.patch
1819
Provides: bsdtar = %{version}-%{release}
1920

2021
BuildRequires: xz-libs
@@ -67,6 +68,9 @@ make %{?_smp_mflags} check
6768
%{_libdir}/pkgconfig/*.pc
6869

6970
%changelog
71+
* Mon Apr 07 2025 Kavya Sree Kaitepalli <kkaitepalli@microsoft.com> - 3.6.1-6
72+
- Patch CVE-2024-48615
73+
7074
* Tue Mar 11 2025 Kanishk Bansal <kanbansal@microsoft.com> - 3.6.1-5
7175
- Patch CVE-2025-25724
7276

toolkit/resources/manifests/package/pkggen_core_aarch64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ openssl-static-1.1.1k-36.cm2.aarch64.rpm
173173
libcap-2.60-4.cm2.aarch64.rpm
174174
libcap-devel-2.60-4.cm2.aarch64.rpm
175175
debugedit-5.0-2.cm2.aarch64.rpm
176-
libarchive-3.6.1-5.cm2.aarch64.rpm
177-
libarchive-devel-3.6.1-5.cm2.aarch64.rpm
176+
libarchive-3.6.1-6.cm2.aarch64.rpm
177+
libarchive-devel-3.6.1-6.cm2.aarch64.rpm
178178
rpm-4.18.0-4.cm2.aarch64.rpm
179179
rpm-build-4.18.0-4.cm2.aarch64.rpm
180180
rpm-build-libs-4.18.0-4.cm2.aarch64.rpm

toolkit/resources/manifests/package/pkggen_core_x86_64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ openssl-static-1.1.1k-36.cm2.x86_64.rpm
173173
libcap-2.60-4.cm2.x86_64.rpm
174174
libcap-devel-2.60-4.cm2.x86_64.rpm
175175
debugedit-5.0-2.cm2.x86_64.rpm
176-
libarchive-3.6.1-5.cm2.x86_64.rpm
177-
libarchive-devel-3.6.1-5.cm2.x86_64.rpm
176+
libarchive-3.6.1-6.cm2.x86_64.rpm
177+
libarchive-devel-3.6.1-6.cm2.x86_64.rpm
178178
rpm-4.18.0-4.cm2.x86_64.rpm
179179
rpm-build-4.18.0-4.cm2.x86_64.rpm
180180
rpm-build-libs-4.18.0-4.cm2.x86_64.rpm

toolkit/resources/manifests/package/toolchain_aarch64.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ krb5-1.19.4-3.cm2.aarch64.rpm
144144
krb5-debuginfo-1.19.4-3.cm2.aarch64.rpm
145145
krb5-devel-1.19.4-3.cm2.aarch64.rpm
146146
krb5-lang-1.19.4-3.cm2.aarch64.rpm
147-
libarchive-3.6.1-5.cm2.aarch64.rpm
148-
libarchive-debuginfo-3.6.1-5.cm2.aarch64.rpm
149-
libarchive-devel-3.6.1-5.cm2.aarch64.rpm
147+
libarchive-3.6.1-6.cm2.aarch64.rpm
148+
libarchive-debuginfo-3.6.1-6.cm2.aarch64.rpm
149+
libarchive-devel-3.6.1-6.cm2.aarch64.rpm
150150
libassuan-2.5.5-2.cm2.aarch64.rpm
151151
libassuan-debuginfo-2.5.5-2.cm2.aarch64.rpm
152152
libassuan-devel-2.5.5-2.cm2.aarch64.rpm

toolkit/resources/manifests/package/toolchain_x86_64.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ krb5-1.19.4-3.cm2.x86_64.rpm
150150
krb5-debuginfo-1.19.4-3.cm2.x86_64.rpm
151151
krb5-devel-1.19.4-3.cm2.x86_64.rpm
152152
krb5-lang-1.19.4-3.cm2.x86_64.rpm
153-
libarchive-3.6.1-5.cm2.x86_64.rpm
154-
libarchive-debuginfo-3.6.1-5.cm2.x86_64.rpm
155-
libarchive-devel-3.6.1-5.cm2.x86_64.rpm
153+
libarchive-3.6.1-6.cm2.x86_64.rpm
154+
libarchive-debuginfo-3.6.1-6.cm2.x86_64.rpm
155+
libarchive-devel-3.6.1-6.cm2.x86_64.rpm
156156
libassuan-2.5.5-2.cm2.x86_64.rpm
157157
libassuan-debuginfo-2.5.5-2.cm2.x86_64.rpm
158158
libassuan-devel-2.5.5-2.cm2.x86_64.rpm

0 commit comments

Comments
 (0)