git archive supports passing generated tar archives through filter
commands like gzip.  Additional filters can be set up using the
configuration variables tar.<name>.command and tar.<name>.remote.

When parsing these config variable names, we currently check that
the second dot is found nine characters into the name, disallowing
filter names with a length of five characters.  Additionally,
git archive crashes when the second dot is omitted:

        $ ./git -c tar.foo=bar archive HEAD >/dev/null
        fatal: Data too large to fit into virtual memory space.

Instead we should check if the second dot exists at all, or if
we only found the first one.

Signed-off-by: Rene Scharfe <rene.scha...@lsrfire.ath.cx>
---
 archive-tar.c       | 2 +-
 t/t5000-tar-tree.sh | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/archive-tar.c b/archive-tar.c
index d1cce46..093d10e 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -335,7 +335,7 @@ static int tar_filter_config(const char *var, const char 
*value, void *data)
        if (prefixcmp(var, "tar."))
                return 0;
        dot = strrchr(var, '.');
-       if (dot == var + 9)
+       if (dot == var + 3)
                return 0;
 
        name = var + 4;
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index e7c240f..3fbd366 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -212,7 +212,8 @@ test_expect_success 'git-archive --prefix=olde-' '
 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.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to