diff --git a/usr.bin/tar/matching.c b/usr.bin/tar/matching.c index 6a3f65bd036e..2ba755fe94a2 100644 --- a/usr.bin/tar/matching.c +++ b/usr.bin/tar/matching.c @@ -102,6 +102,9 @@ add_pattern(struct bsdtar *bsdtar, struct match **list, const char *pattern) if (pattern[0] == '/') pattern++; strcpy(match->pattern, pattern); + /* Both "foo/" and "foo" should match "foo/bar". */ + if (match->pattern[strlen(match->pattern)-1] == '/') + match->pattern[strlen(match->pattern)-1] = '\0'; match->next = *list; *list = match; match->matches = 0;