summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e0b3cc0)
raw | patch | inline | side by side (parent: e0b3cc0)
author | Frank Lichtenheld <flichtenheld@astaro.com> | |
Sat, 18 Apr 2009 14:14:02 +0000 (16:14 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 18 Apr 2009 20:06:40 +0000 (13:06 -0700) |
Signed-off-by: Frank Lichtenheld <flichtenheld@astaro.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-init-db.c | patch | blob | history | |
t/t0001-init.sh | patch | blob | history |
diff --git a/builtin-init-db.c b/builtin-init-db.c
index d30c3fe2ca542b061ab8b7a7696cdd5416e17147..6cc945d5075b03727f93194cd67122e6bff49764 100644 (file)
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);
if (!template_dir[0])
return;
+ template_len = strlen(template_dir);
+ if (PATH_MAX <= (template_len+strlen("/config")))
+ die("insanely long template path %s", template_dir);
strcpy(template_path, template_dir);
- template_len = strlen(template_path);
if (template_path[template_len-1] != '/') {
template_path[template_len++] = '/';
template_path[template_len] = 0;
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 5ac0a273a94c033fbb7c48cb9a22e44c389e0f7d..e3d846420dc09e7b24876b291b9e546ac0628ed3 100755 (executable)
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
x`git config -f shared-honor-global/.git/config core.sharedRepository`
'
+test_expect_success 'init rejects insanely long --template' '
+ (
+ insane=$(printf "x%09999dx" 1) &&
+ mkdir test &&
+ cd test &&
+ test_must_fail git init --template=$insane
+ )
+'
+
test_done