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

[PATCH 5/5] refspec.c: use rhs in parse_refspec instead of potentially uninitialized item->dst

From
Stefan Beller <sbeller@google.com>
Date
May 30, 2018, 17:04 UTC
Message-ID
<20180530170433.191495-1-sbeller@google.com>

'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
Next: Junio C Hamano
Message 1 of 4 in “refspec.c: use rhs in parse_refspec instead of potentially uninitialized item->dst”
  1. 5/5 refspec.c: use rhs in parse_refspec instead of potentially uninitialized item->dstStefan Beller, May 30, 2018
  2. Junio C HamanoJun 1, 2018
  3. Junio C HamanoJun 1, 2018
  4. Stefan BellerJun 1, 2018

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.