| Patrick Williams | 705982a | 2024-01-12 09:51:57 -0600 | [diff] [blame] | 1 | From 3fa2ae78db9b31edb4c22f3b5cd36c6c972947f1 Mon Sep 17 00:00:00 2001 | 
|  | 2 | From: Florian Festi <ffesti@redhat.com> | 
|  | 3 | Date: Wed, 26 Jul 2023 15:01:35 +0200 | 
|  | 4 | Subject: [PATCH] Duplicate filename before passing it to basename | 
|  | 5 |  | 
|  | 6 | basename is allowed change the string passed to it. While we don't need | 
|  | 7 | the filename after that just casting away the const seems a bit too | 
|  | 8 | hacky. | 
|  | 9 |  | 
|  | 10 | Upstream-Status: Backport [https://github.com/rpm-software-management/rpm/commit/3fa2ae78db9b31edb4c22f3b5cd36c6c972947f1] | 
|  | 11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | 
|  | 12 | --- | 
|  | 13 | tools/rpmuncompress.c | 4 +++- | 
|  | 14 | 1 file changed, 3 insertions(+), 1 deletion(-) | 
|  | 15 |  | 
|  | 16 | diff --git a/tools/rpmuncompress.c b/tools/rpmuncompress.c | 
|  | 17 | index 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 | -- | 
|  | 39 | 2.43.0 | 
|  | 40 |  |