Skip to content

Commit 34b1a0d

Browse files
peffgitster
authored andcommitted
submodule: handle NULL value when parsing submodule.*.branch
We record the submodule branch config value as a string, so config that uses an implicit bool like: [submodule "foo"] branch will cause us to segfault. Note that unlike most other config-parsing bugs of this class, this can be triggered by parsing a bogus .gitmodules file (which we might do after cloning a malicious repository). I don't think the security implications are important, though. It's always a strict NULL dereference, not an out-of-bounds read or write. So we should reliably kill the process. That may be annoying, but the impact is limited to the attacker preventing the victim from successfully using "git clone --recurse-submodules", etc, on the malicious repo. The "branch" entry is the only one with this problem; other strings like "path" and "url" already check for NULL. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 89086c9 commit 34b1a0d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

submodule-config.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,9 @@ static int parse_config(const char *var, const char *value,
516516
submodule->recommend_shallow =
517517
git_config_bool(var, value);
518518
} else if (!strcmp(item.buf, "branch")) {
519-
if (!me->overwrite && submodule->branch)
519+
if (!value)
520+
ret = config_error_nonbool(var);
521+
else if (!me->overwrite && submodule->branch)
520522
warn_multiple_config(me->treeish_name, submodule->name,
521523
"branch");
522524
else {

0 commit comments

Comments
 (0)