This is fewer lines of code, but more importantly, fixes a bogus pointer offset. We are looking for "tar." in the section, but later assume that the dot we found is at offset 9, not 3. This is a holdover from an earlier iteration of 767cf45 which called the section "tarfilter". As a result, we could erroneously reject some filters with dots in their name, as well as read uninitialized memory. Reported by (and test by) René Scharfe. Signed-off-by: Jeff King <peff@xxxxxxxx> --- This obviously replaces René's patch. It might make more sense to just put his patch onto maint, and build this on top; then this patch can get squashed into the next one (which just updates the uninteresting callsites). archive-tar.c | 10 +--------- t/t5000-tar-tree.sh | 3 ++- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/archive-tar.c b/archive-tar.c index 0ba3f25..68dbe59 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -325,20 +325,12 @@ static int tar_filter_config(const char *var, const char *value, void *data) static int tar_filter_config(const char *var, const char *value, void *data) { struct archiver *ar; - const char *dot; const char *name; const char *type; int namelen; - if (prefixcmp(var, "tar.")) + if (match_config_key(var, "tar", &name, &namelen, &type) < 0 || !name) return 0; - dot = strrchr(var, '.'); - if (dot == var + 9) - return 0; - - name = var + 4; - namelen = dot - name; - type = dot + 1; ar = find_tar_filter(name, namelen); if (!ar) { diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index ecf00ed..517ae04 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -283,7 +283,8 @@ test_expect_success 'setup tar filters' ' test_expect_success 'setup tar filters' ' git config tar.tar.foo.command "tr ab ba" && git config tar.bar.command "tr ab ba" && - git config tar.bar.remote true + git config tar.bar.remote true && + git config tar.invalid baz ' test_expect_success 'archive --list mentions user filter' ' -- 1.8.1.rc1.10.g7d71f7b -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html