git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] archive-tar: fix sanity check in config parsing
@ 2013-01-13 17:42 René Scharfe
  2013-01-13 20:00 ` Jeff King
  0 siblings, 1 reply; 31+ messages in thread
From: René Scharfe @ 2013-01-13 17:42 UTC (permalink / raw)
  To: git discussion list; +Cc: Jeff King, Junio C Hamano

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.scharfe@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

^ permalink raw reply related	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2013-01-23 20:51 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-13 17:42 [PATCH] archive-tar: fix sanity check in config parsing René Scharfe
2013-01-13 20:00 ` Jeff King
2013-01-14  8:17   ` Joachim Schmitz
2013-01-14 12:44     ` Jeff King
2013-01-14 14:58       ` Jeff King
2013-01-14 15:00         ` [PATCH 1/6] config: add helper function for parsing key names Jeff King
2013-01-14 18:08           ` Junio C Hamano
2013-01-15 16:04             ` Jeff King
2013-01-15 17:07               ` Junio C Hamano
2013-01-18 20:53                 ` Junio C Hamano
2013-01-23  6:21                   ` [PATCHv2 0/8] config key-parsing cleanups Jeff King
2013-01-23  6:23                     ` [PATCHv2 1/8] config: add helper function for parsing key names Jeff King
2013-01-23  6:23                     ` [PATCHv2 2/8] archive-tar: use parse_config_key when parsing config Jeff King
2013-01-23  6:24                     ` [PATCHv2 3/8] convert some config callbacks to parse_config_key Jeff King
2013-01-23  6:25                     ` [PATCHv2 4/8] userdiff: drop parse_driver function Jeff King
2013-01-23  6:25                     ` [PATCHv2 5/8] submodule: use parse_config_key when parsing config Jeff King
2013-01-23 20:45                       ` Jens Lehmann
2013-01-23  6:26                     ` [PATCHv2 6/8] submodule: simplify memory handling in config parsing Jeff King
2013-01-23 20:51                       ` Jens Lehmann
2013-01-23  6:27                     ` [PATCHv2 7/8] help: use parse_config_key for man config Jeff King
2013-01-23  6:27                     ` [PATCHv2 8/8] reflog: use parse_config_key in config callback Jeff King
2013-01-23  7:04                       ` Junio C Hamano
2013-01-23  7:27                     ` [PATCHv2 0/8] config key-parsing cleanups Jonathan Nieder
2013-01-14 15:02         ` [PATCH 2/6] archive-tar: use match_config_key when parsing config Jeff King
2013-01-14 15:03         ` [PATCH 3/6] convert some config callbacks to match_config_key Jeff King
2013-01-14 16:55           ` Jonathan Nieder
2013-01-14 17:06             ` Jeff King
2013-01-14 18:05               ` Jeff King
2013-01-14 15:04         ` [PATCH 4/6] userdiff: drop parse_driver function Jeff King
2013-01-14 15:04         ` [PATCH 5/6] submodule: use match_config_key when parsing config Jeff King
2013-01-14 15:07         ` [PATCH 6/6] submodule: simplify memory handling in config parsing Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).