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>
Jharrod LaFon committed
Aug 19, 2013 at 09:26 UTC
4b05440283350ec3b01afabe847d9ce5cf4cbdb7
2 files changed
+16
submodule.c
+6
@@ -134,6 +134,9 @@ int parse_submodule_config_option(const char *var, const char *value)
134
return 0;
135
136
if (!strcmp(key, "path")) {
137
+ if (!value)
138
+ return config_error_nonbool(var);
139
+
140
config = unsorted_string_list_lookup(&config_name_for_path, value);
141
if (config)
142
free(config->util);
@@ -151,6 +154,9 @@ int parse_submodule_config_option(const char *var, const char *value)
154
} else if (!strcmp(key, "ignore")) {
155
char *name_cstr;
156
157
+ if (!value)
158
+ return config_error_nonbool(var);
159
+
160
if (strcmp(value, "untracked") && strcmp(value, "dirty") &&
161
strcmp(value, "all") && strcmp(value, "none")) {
162
warning("Invalid parameter \"%s\" for config option \"submodule.%s.ignore\"", value, var);
t/t7400-submodule-basic.sh
+10
@@ -18,6 +18,16 @@ test_expect_success 'setup - initial commit' '
18
git branch initial
19
'
20
21
+test_expect_success 'configuration parsing' '
22
+ test_when_finished "rm -f .gitmodules" &&
23
+ cat >.gitmodules <<-\EOF &&
24
+ [submodule "s"]
25
+ path
26
+ ignore
27
+ EOF
28
+ test_must_fail git status
29
+'
30
+
31
test_expect_success 'setup - repository in init subdirectory' '
32
mkdir init &&
33
(