git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: nate@roosteregg.cc
To: git@vger.kernel.org
Cc: Nate Avers <nate@roosteregg.cc>
Subject: [PATCH 1/2] notes.c: fix a segfault in notes_display_config()
Date: Sun, 22 Nov 2020 22:23:41 -0500	[thread overview]
Message-ID: <20201123032342.24566-2-nate@roosteregg.cc> (raw)
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


  reply	other threads:[~2020-11-23  3:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23  3:23 [PATCH 0/2] Fix a segfault in git log --notes nate
2020-11-23  3:23 ` nate [this message]
2020-11-23  6:59   ` [PATCH 1/2] notes.c: fix a segfault in notes_display_config() Junio C Hamano
2020-11-23  3:23 ` [PATCH 2/2] t3301: test proper exit response to no-value notes.displayRef nate
2020-11-23 18:44   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201123032342.24566-2-nate@roosteregg.cc \
    --to=nate@roosteregg.cc \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).