Skip to content

Commit

Permalink
Duplicate filename before passing it to basename
Browse files Browse the repository at this point in the history
basename is allowed change the string passed to it. While we don't need
the filename after that just casting away the const seems a bit too
hacky.
  • Loading branch information
ffesti committed Jul 26, 2023
1 parent b2e6764 commit 3fa2ae7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/rpmuncompress.c
Expand Up @@ -98,7 +98,8 @@ static char *doUntar(const char *fn)
if (needtar) {
rasprintf(&buf, "%s '%s' | %s %s -", zipper, fn, tar, taropts);
} else if (at->compressed == COMPRESSED_GEM) {
const char *bn = basename(fn);
char *tmp = xstrdup(fn);
const char *bn = basename(tmp);
size_t nvlen = strlen(bn) - 3;
char *gem = rpmGetPath("%{__gem}", NULL);
char *gemspec = NULL;
Expand All @@ -112,6 +113,7 @@ static char *doUntar(const char *fn)

free(gemspec);
free(gem);
free(tmp);
} else {
rasprintf(&buf, "%s '%s'", zipper, fn);
}
Expand Down

0 comments on commit 3fa2ae7

Please sign in to comment.