]> git.ipfire.org Git - thirdparty/libarchive.git/commit
tar: fix bug when -s/a/b/ used more than once with b flag (#2435)
authorStephane Chazelas <stephane+gh@chazelas.org>
Fri, 27 Dec 2024 23:20:16 +0000 (23:20 +0000)
committerGitHub <noreply@github.com>
Fri, 27 Dec 2024 23:20:16 +0000 (15:20 -0800)
commit4d5106f2b5e48a34ec0e341974737252ed5aae84
tree89aeff995b59d3c6f25b1163171b83c141bc5ff5
parent4ebca5ff8312ea15c470067969e43d452e2dceeb
tar: fix bug when -s/a/b/ used more than once with b flag (#2435)

When the -s/regexp/replacement/ option was used with the b flag more
than once, the result of the previous substitution was appended to the
previous subject instead of replacing it. Fixed it by making sure the
subject is made the empty string before the call to realloc_strcat().
That in effect makes it more like a realloc_strcpy(), but creating a new
realloc_strcpy() function for that one usage doesn't feel worth it.

Resolves Issue libarchive/libarchive#2414

Co-authored-by: Stephane Chazelas <stephane@chazelas.org>
tar/subst.c
tar/test/test_option_s.c