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

[PATCH 2/2] bisect--helper: verify HEAD could be parsed before continuing

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
May 21, 2019, 17:50 UTC
Message-ID
<f5fa20d2a33e0cacc649c86b540d7d8eeff30a45.1558461018.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.221.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

In 06f5608c14e6 (bisect--helper: `bisect_start` shell function partially in C, 2019-01-02), we introduced a call to `get_oid()` and did not check whether it succeeded before using its output.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin/bisect--helper.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index e7325fe37f..1fbe156e67 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -570,7 +570,10 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
 	write_file(git_path_bisect_start(), "%s\n", start_head.buf);
 
 	if (no_checkout) {
-		get_oid(start_head.buf, &oid);
+		if (get_oid(start_head.buf, &oid) < 0) {
+			retval = error(_("invalid ref: '%s'"), start_head.buf);
+			goto finish;
+		}
 		if (update_ref(NULL, "BISECT_HEAD", &oid, NULL, 0,
 			       UPDATE_REFS_MSG_ON_ERR)) {
 			retval = -1;
-- 
gitgitgadget
Previous: Junio C Hamano
Message 4 of 4 in “Fix two issues pointed out by Coverity”
  1. 0/2 Fix two issues pointed out by CoverityJohannes Schindelin via GitGitGadget, May 21, 2019
  2. 1/2 rebase: replace incorrect logical negation by correct bitwise oneJohannes Schindelin via GitGitGadget, May 21, 2019
  3. Junio C HamanoMay 28, 2019
  4. 2/2 bisect--helper: verify HEAD could be parsed before continuingJohannes Schindelin via GitGitGadget, May 21, 2019

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.