git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH 2/2] bisect--helper: verify HEAD could be parsed before continuing
Date: Tue, 21 May 2019 10:50:21 -0700 (PDT)	[thread overview]
Message-ID: <f5fa20d2a33e0cacc649c86b540d7d8eeff30a45.1558461018.git.gitgitgadget@gmail.com> (raw)
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

      parent reply	other threads:[~2019-05-21 17:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-21 17:50 [PATCH 0/2] Fix two issues pointed out by Coverity Johannes Schindelin via GitGitGadget
2019-05-21 17:50 ` [PATCH 1/2] rebase: replace incorrect logical negation by correct bitwise one Johannes Schindelin via GitGitGadget
2019-05-28 18:25   ` Junio C Hamano
2019-05-21 17:50 ` Johannes Schindelin via GitGitGadget [this message]

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=f5fa20d2a33e0cacc649c86b540d7d8eeff30a45.1558461018.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    /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).