]> git.ipfire.org Git - thirdparty/git.git/commit
submodule: handle NULL value when parsing submodule.*.branch
authorJeff King <peff@peff.net>
Thu, 7 Dec 2023 07:11:29 +0000 (02:11 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 Dec 2023 23:24:47 +0000 (08:24 +0900)
commit34b1a0d320e3a1531997d6681bacffbe9da7a046
tree2e1c5b5549ebbf434a582e56e0e8f649420164fc
parent89086c9466624ca0b53f04374e293a7afcec592b
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
submodule-config.c