mirror of
https://github.com/git/git
synced 2024-08-28 20:20:07 +00:00
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>
This commit is contained in:
parent
e0b3cc0dff
commit
32d1776b13
|
@ -122,8 +122,10 @@ static void copy_templates(const char *template_dir)
|
||||||
template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);
|
template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);
|
||||||
if (!template_dir[0])
|
if (!template_dir[0])
|
||||||
return;
|
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);
|
strcpy(template_path, template_dir);
|
||||||
template_len = strlen(template_path);
|
|
||||||
if (template_path[template_len-1] != '/') {
|
if (template_path[template_len-1] != '/') {
|
||||||
template_path[template_len++] = '/';
|
template_path[template_len++] = '/';
|
||||||
template_path[template_len] = 0;
|
template_path[template_len] = 0;
|
||||||
|
|
|
@ -199,4 +199,13 @@ test_expect_success 'init honors global core.sharedRepository' '
|
||||||
x`git config -f shared-honor-global/.git/config core.sharedRepository`
|
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
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue