git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] notes.c: fix a segfault in notes_display_config()

From
nate@roosteregg.cc <nate@roosteregg.cc>
Date
Nov 23, 2020, 03:23 UTC
Message-ID
<20201123032342.24566-2-nate@roosteregg.cc>
In-Reply-To
<20201123032342.24566-1-nate@roosteregg.cc>
From: Nate Avers <nate@roosteregg.cc>

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>
---
 notes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/notes.c b/notes.c
index 564baac64d..d5ac081e76 100644
--- a/notes.c
+++ b/notes.c
@@ -970,7 +970,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);
 	}
 
-- 
2.27.0
Previous: nate@roosteregg.ccNext: Junio C Hamano
Message 2 of 5 in “Fix a segfault in git log --notes”
  1. 0/2 Fix a segfault in git log --notesnate@roosteregg.cc, Nov 23, 2020
  2. 1/2 notes.c: fix a segfault in notes_display_config()nate@roosteregg.cc, Nov 23, 2020
  3. Junio C HamanoNov 23, 2020
  4. 2/2 t3301: test proper exit response to no-value notes.displayRef.nate@roosteregg.cc, Nov 23, 2020
  5. Junio C HamanoNov 23, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.