git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: git@vger.kernel.org
Cc: bmwill@google.com, Stefan Beller <sbeller@google.com>
Subject: [PATCH 5/5] refspec.c: use rhs in parse_refspec instead of potentially uninitialized item->dst
Date: Wed, 30 May 2018 10:04:33 -0700	[thread overview]
Message-ID: <20180530170433.191495-1-sbeller@google.com> (raw)

'item->dst' has not been assigned if '!rhs' is true. As the caller is allowed to pass in uninitialized
memory (we don't assume 'item' was zeroed out before calling), this fixes an access to
uninitialized memory.

Signed-off-by: Stefan Beller <sbeller@google.com>
---

applies on bw/refspec-api

 refspec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/refspec.c b/refspec.c
index c59a4ccf1e5..ea169dec0d3 100644
--- a/refspec.c
+++ b/refspec.c
@@ -108,7 +108,7 @@ static int parse_refspec(struct refspec_item *item, const char *refspec, int fet
 		 * - empty is not allowed.
 		 * - otherwise it must be a valid looking ref.
 		 */
-		if (!item->dst) {
+		if (!rhs) {
 			if (check_refname_format(item->src, flags))
 				return 0;
 		} else if (!*item->dst) {
-- 
2.17.0.582.gccdcbd54c44.dirty


             reply	other threads:[~2018-05-30 17:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-30 17:04 Stefan Beller [this message]
2018-06-01  2:01 ` [PATCH 5/5] refspec.c: use rhs in parse_refspec instead of potentially uninitialized item->dst Junio C Hamano
2018-06-01  2:46   ` Junio C Hamano
2018-06-01 19:38     ` Stefan Beller

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=20180530170433.191495-1-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=bmwill@google.com \
    --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).