]> 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)
committerMartin Matuska <martin@matuska.de>
Tue, 11 Mar 2025 09:29:11 +0000 (10:29 +0100)
commit562cdbcc20b3c9d215b66d42d6ddbd3421434e44
treebb2534858f4c8533279e7319ad7c97fd56e5935a
parent287b153444bad194bc15c929933f12e96e92a6bc
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>
(cherry picked from commit 4d5106f2b5e48a34ec0e341974737252ed5aae84)
tar/subst.c
tar/test/test_option_s.c