From: Colin Percival Date: Sat, 20 Aug 2011 07:19:41 +0000 (-0400) Subject: Fix handling of ~ within the target of a 'tar -s' directive. X-Git-Tag: v3.0.0a~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ae2307ae173408e1e970e214d2bea1735aa2bc9;p=thirdparty%2Flibarchive.git Fix handling of ~ within the target of a 'tar -s' directive. According to the man page, "~ is substituted with the match", but prior to this commit it was substituted with the entire source string up to the end of the matching region. -s /o/_~/, prior to this commit: foo -> f_foo -s /o/_~/, after this commit: foo -> f_oo Reported by: Carlo Teubner SVN-Revision: 3643 --- diff --git a/tar/subst.c b/tar/subst.c index 05ec42b7b..b73e78c42 100644 --- a/tar/subst.c +++ b/tar/subst.c @@ -215,7 +215,9 @@ apply_substitution(struct bsdtar *bsdtar, const char *name, char **result, int s for (i = 0, j = 0; rule->result[i] != '\0'; ++i) { if (rule->result[i] == '~') { realloc_strncat(result, rule->result + j, i - j); - realloc_strncat(result, name, matches[0].rm_eo); + realloc_strncat(result, + name + matches[0].rm_so, + matches[0].rm_eo - matches[0].rm_so); j = i + 1; continue; }