avoid segfault on submodule.*.path set to an empty "true"

Git fails due to a segmentation fault if a submodule path is empty.
Here is an example .gitmodules that will cause a segmentation fault:

    [submodule "foo-module"]
      path
      url = http://host/repo.git
    $ git status
    Segmentation fault (core dumped)

This is because the parsing of "submodule.*.path" is not prepared to
see a value-less "true" and assumes that the value is always
non-NULL (parsing of "ignore" has the same problem).

Fix it by checking the NULL-ness of value and complain with
config_error_nonbool().

Signed-off-by: Jharrod LaFon <jlafon@eyesopen.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jharrod LaFon
2013-08-19 09:26:56 -07:00
committed by Junio C Hamano
parent f59bebb78e
commit 4b05440283
2 changed files with 16 additions and 0 deletions

View File

@ -18,6 +18,16 @@ test_expect_success 'setup - initial commit' '
git branch initial
'
test_expect_success 'configuration parsing' '
test_when_finished "rm -f .gitmodules" &&
cat >.gitmodules <<-\EOF &&
[submodule "s"]
path
ignore
EOF
test_must_fail git status
'
test_expect_success 'setup - repository in init subdirectory' '
mkdir init &&
(