|
| 1 | +From eb012d7c582f2fd1921d7ddd94ae5b5b09a625d7 Mon Sep 17 00:00:00 2001 |
| 2 | +From: kavyasree <kkaitepalli@microsoft.com> |
| 3 | +Date: Tue, 19 Nov 2024 13:00:38 +0530 |
| 4 | +Subject: [PATCH] Fix CVE-2023-39804 |
| 5 | + |
| 6 | +--- |
| 7 | + src/xheader.c | 17 +++++++++-------- |
| 8 | + 1 file changed, 9 insertions(+), 8 deletions(-) |
| 9 | + |
| 10 | +diff --git a/src/xheader.c b/src/xheader.c |
| 11 | +index 229137e..078a12d 100644 |
| 12 | +--- a/src/xheader.c |
| 13 | ++++ b/src/xheader.c |
| 14 | +@@ -638,11 +638,11 @@ static struct xhdr_tab const * |
| 15 | + locate_handler (char const *keyword) |
| 16 | + { |
| 17 | + struct xhdr_tab const *p; |
| 18 | +- |
| 19 | + for (p = xhdr_tab; p->keyword; p++) |
| 20 | + if (p->prefix) |
| 21 | + { |
| 22 | +- if (strncmp (p->keyword, keyword, strlen(p->keyword)) == 0) |
| 23 | ++ size_t kwlen = strlen (p->keyword); |
| 24 | ++ if (keyword[kwlen] == '.' && strncmp (p->keyword, keyword, kwlen) == 0) |
| 25 | + return p; |
| 26 | + } |
| 27 | + else |
| 28 | +@@ -1717,19 +1717,20 @@ xattr_decoder (struct tar_stat_info *st, |
| 29 | + char const *keyword, char const *arg, size_t size) |
| 30 | + { |
| 31 | + char *xstr, *xkey; |
| 32 | +- |
| 33 | ++ |
| 34 | + /* copy keyword */ |
| 35 | +- size_t klen_raw = strlen (keyword); |
| 36 | +- xkey = alloca (klen_raw + 1); |
| 37 | +- memcpy (xkey, keyword, klen_raw + 1) /* including null-terminating */; |
| 38 | ++ xkey = xstrdup (keyword); |
| 39 | + |
| 40 | + /* copy value */ |
| 41 | +- xstr = alloca (size + 1); |
| 42 | ++ xstr = xmalloc (size + 1); |
| 43 | + memcpy (xstr, arg, size + 1); /* separator included, for GNU tar '\n' */; |
| 44 | + |
| 45 | + xattr_decode_keyword (xkey); |
| 46 | + |
| 47 | +- xheader_xattr_add (st, xkey + strlen("SCHILY.xattr."), xstr, size); |
| 48 | ++ xheader_xattr_add (st, xkey + strlen ("SCHILY.xattr."), xstr, size); |
| 49 | ++ |
| 50 | ++ free (xkey); |
| 51 | ++ free (xstr); |
| 52 | + } |
| 53 | + |
| 54 | + static void |
| 55 | +-- |
| 56 | +2.34.1 |
| 57 | + |
0 commit comments