diff options
author | Jeff King <peff@peff.net> | 2013-01-23 01:23:27 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-01-23 08:41:50 -0800 |
commit | 785a04298177e155dc7391e7234945b38b624e34 (patch) | |
tree | f952b01753afe3f46393957ba3b13484153d432d /archive-tar.c | |
parent | 1b86bbb0ade4641c2da0dc74ebca1c09ec772bb4 (diff) | |
download | git-785a04298177e155dc7391e7234945b38b624e34.tar.gz |
archive-tar: use parse_config_key when parsing config
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@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'archive-tar.c')
-rw-r--r-- | archive-tar.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/archive-tar.c b/archive-tar.c index d1cce46e33..719b6298e6 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -327,20 +327,12 @@ static struct archiver *find_tar_filter(const char *name, int len) 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 (parse_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) { |