]> git.ipfire.org Git - thirdparty/git.git/commitdiff
notes.c: fix a segfault in notes_display_config()
authorNate Avers <nate@roosteregg.cc>
Mon, 23 Nov 2020 03:23:41 +0000 (22:23 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Nov 2020 18:42:22 +0000 (10:42 -0800)
If notes.displayRef is configured with no value[1], control should be
returned to the caller when notes.c:notes_display_config() checks if 'v'
is NULL. Otherwise, both git log --notes and git diff-tree --notes will
subsequently segfault when refs.h:has_glob_specials() calls strpbrk()
with a NULL first argument.

[1] Examples:
.git/config:
[notes]
displayRef
$ git -c notes.displayRef [...]

Signed-off-by: Nate Avers <nate@roosteregg.cc>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
notes.c

diff --git a/notes.c b/notes.c
index 03e7d0cd2ddaf623fd41d4969348c624beee56d5..928dde8b347734861d26743348106396b46025ca 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -967,7 +967,7 @@ static int notes_display_config(const char *k, const char *v, void *cb)
 
        if (*load_refs && !strcmp(k, "notes.displayref")) {
                if (!v)
-                       config_error_nonbool(k);
+                       return config_error_nonbool(k);
                string_list_add_refs_by_glob(&display_notes_refs, v);
        }