diff options
author | Jeff King <peff@peff.net> | 2008-07-28 02:02:04 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-07-27 23:14:03 -0700 |
commit | 172035f044ebae283f23e95e3ec4d119dc8057cb (patch) | |
tree | 6c6dad8917da10a806c4f0111da179e28b8f2860 /builtin-init-db.c | |
parent | 8e1db3871c767cb17b5e0eeb7bea8d967821a055 (diff) | |
download | git-172035f044ebae283f23e95e3ec4d119dc8057cb.tar.gz |
init: handle empty "template" parameter
If a user passes "--template=", then our template parameter
is blank. Unfortunately, copy_templates() assumes it has at
least one character, and does all sorts of bad things like
reading from template[-1] and then proceeding to link all of
'/' into the .git directory.
This patch just checks for that condition in copy_templates
and aborts. As a side effect, this means that --template=
now has the meaning "don't copy any templates."
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-init-db.c')
-rw-r--r-- | builtin-init-db.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin-init-db.c b/builtin-init-db.c index 38b4fcb6db..baf0d09ac4 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -117,6 +117,8 @@ static void copy_templates(const char *template_dir) template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT); if (!template_dir) template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR); + if (!template_dir[0]) + return; strcpy(template_path, template_dir); template_len = strlen(template_path); if (template_path[template_len-1] != '/') { |