summaryrefslogtreecommitdiff
path: root/builtin-init-db.c
diff options
context:
space:
mode:
authorFrank Lichtenheld <flichtenheld@astaro.com>2009-04-18 16:14:02 +0200
committerJunio C Hamano <gitster@pobox.com>2009-04-18 13:06:40 -0700
commit32d1776b1341c17b99da862e80ddf151a5b558fe (patch)
tree6917dd74528fbc8397edf2a3f9786504bab3430e /builtin-init-db.c
parente0b3cc0dffbc965ffa33155cbdcf8d44716c134c (diff)
downloadgit-32d1776b1341c17b99da862e80ddf151a5b558fe.tar.gz
init: Do not segfault on big GIT_TEMPLATE_DIR environment variable
Signed-off-by: Frank Lichtenheld <flichtenheld@astaro.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-init-db.c')
-rw-r--r--builtin-init-db.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin-init-db.c b/builtin-init-db.c
index d30c3fe2ca..6cc945d507 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -122,8 +122,10 @@ static void copy_templates(const char *template_dir)
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;