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>
This commit is contained in:

committed by
Junio C Hamano

parent
1e5f7add98
commit
d65d2b2fb4
@ -127,6 +127,8 @@ static void copy_templates(const char *template_dir)
|
||||
template_dir = strbuf_detach(&d, NULL);
|
||||
}
|
||||
}
|
||||
if (!template_dir[0])
|
||||
return;
|
||||
strcpy(template_path, template_dir);
|
||||
template_len = strlen(template_path);
|
||||
if (template_path[template_len-1] != '/') {
|
||||
|
Reference in New Issue
Block a user