blob: f9b809d167628f70ce475bf1f0d510dc7b0ec49c [file] [log] [blame]
Patrick Williams705982a2024-01-12 09:51:57 -06001From 3fa2ae78db9b31edb4c22f3b5cd36c6c972947f1 Mon Sep 17 00:00:00 2001
2From: Florian Festi <ffesti@redhat.com>
3Date: Wed, 26 Jul 2023 15:01:35 +0200
4Subject: [PATCH] Duplicate filename before passing it to basename
5
6basename is allowed change the string passed to it. While we don't need
7the filename after that just casting away the const seems a bit too
8hacky.
9
10Upstream-Status: Backport [https://github.com/rpm-software-management/rpm/commit/3fa2ae78db9b31edb4c22f3b5cd36c6c972947f1]
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 tools/rpmuncompress.c | 4 +++-
14 1 file changed, 3 insertions(+), 1 deletion(-)
15
16diff --git a/tools/rpmuncompress.c b/tools/rpmuncompress.c
17index 58ddf5683..e13cc6a66 100644
18--- a/tools/rpmuncompress.c
19+++ b/tools/rpmuncompress.c
20@@ -98,7 +98,8 @@ static char *doUntar(const char *fn)
21 if (needtar) {
22 rasprintf(&buf, "%s '%s' | %s %s -", zipper, fn, tar, taropts);
23 } else if (at->compressed == COMPRESSED_GEM) {
24- const char *bn = basename(fn);
25+ char *tmp = xstrdup(fn);
26+ const char *bn = basename(tmp);
27 size_t nvlen = strlen(bn) - 3;
28 char *gem = rpmGetPath("%{__gem}", NULL);
29 char *gemspec = NULL;
30@@ -112,6 +113,7 @@ static char *doUntar(const char *fn)
31
32 free(gemspec);
33 free(gem);
34+ free(tmp);
35 } else {
36 rasprintf(&buf, "%s '%s'", zipper, fn);
37 }
38--
392.43.0
40