|
| 1 | +From 0a35ab97fae6fb9acecab46b570c14e3be1646e7 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Peter Kaestle <peter@piie.net> |
| 3 | +Date: Wed, 5 Mar 2025 15:34:44 +0100 |
| 4 | +Subject: [PATCH] unzip/bsdunzip.c: fix NULL ptr dereference issue inside |
| 5 | + list() |
| 6 | + |
| 7 | +Fix CVE-2025-1632 by detecting NULL return of archive_entry_pathname() |
| 8 | +and replacing it by "INVALID PATH" string. |
| 9 | + |
| 10 | +Error poc: https://github.com/Ekkosun/pocs/blob/main/bsdunzip-poc |
| 11 | + |
| 12 | +Upstream Reference : https://github.com/libarchive/libarchive/pull/2532 |
| 13 | + |
| 14 | +Signed-off-by: Peter Kaestle <peter@piie.net> |
| 15 | +--- |
| 16 | + unzip/bsdunzip.c | 10 +++++++--- |
| 17 | + 1 file changed, 7 insertions(+), 3 deletions(-) |
| 18 | + |
| 19 | +diff --git a/unzip/bsdunzip.c b/unzip/bsdunzip.c |
| 20 | +index 7c8cafc3e..4a9028b79 100644 |
| 21 | +--- a/unzip/bsdunzip.c |
| 22 | ++++ b/unzip/bsdunzip.c |
| 23 | +@@ -876,6 +876,7 @@ list(struct archive *a, struct archive_entry *e) |
| 24 | + char buf[20]; |
| 25 | + time_t mtime; |
| 26 | + struct tm *tm; |
| 27 | ++ const char *pathname; |
| 28 | + |
| 29 | + mtime = archive_entry_mtime(e); |
| 30 | + tm = localtime(&mtime); |
| 31 | +@@ -884,22 +885,25 @@ list(struct archive *a, struct archive_entry *e) |
| 32 | + else |
| 33 | + strftime(buf, sizeof(buf), "%m-%d-%g %R", tm); |
| 34 | + |
| 35 | ++ pathname = archive_entry_pathname(e); |
| 36 | ++ if (!pathname) |
| 37 | ++ pathname = ""; |
| 38 | + if (!zipinfo_mode) { |
| 39 | + if (v_opt == 1) { |
| 40 | + printf(" %8ju %s %s\n", |
| 41 | + (uintmax_t)archive_entry_size(e), |
| 42 | +- buf, archive_entry_pathname(e)); |
| 43 | ++ buf, pathname); |
| 44 | + } else if (v_opt == 2) { |
| 45 | + printf("%8ju Stored %7ju 0%% %s %08x %s\n", |
| 46 | + (uintmax_t)archive_entry_size(e), |
| 47 | + (uintmax_t)archive_entry_size(e), |
| 48 | + buf, |
| 49 | + 0U, |
| 50 | +- archive_entry_pathname(e)); |
| 51 | ++ pathname); |
| 52 | + } |
| 53 | + } else { |
| 54 | + if (Z1_opt) |
| 55 | +- printf("%s\n",archive_entry_pathname(e)); |
| 56 | ++ printf("%s\n", pathname); |
| 57 | + } |
| 58 | + ac(archive_read_data_skip(a)); |
| 59 | + } |
0 commit comments