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

[PATCH] sanity check in add_packed_git()

From
PRPavel Roskin <proski@gnu.org>
Date
Dec 21, 2005, 23:47 UTC
Message-ID
<1135208829.15567.18.camel@dv>

add_packed_git() tries to get the pack SHA1 by parsing its name. It may access uninitialized memory for packs with short names.

Signed-off-by: Pavel Roskin <proski@gnu.org>
diff --git a/sha1_file.c b/sha1_file.c
index fa22e9c..d83d824 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -464,7 +464,7 @@ struct packed_git *add_packed_git(char *
 	p->pack_last_used = 0;
 	p->pack_use_cnt = 0;
 	p->pack_local = local;
-	if (!get_sha1_hex(path + path_len - 40 - 4, sha1))
+	if ((path_len > 44) && !get_sha1_hex(path + path_len - 44, sha1))
 		memcpy(p->sha1, sha1, 20);
 	return p;
 }
-- 
Regards,
Pavel Roskin
Next: Junio C Hamano
Message 1 of 4 in “sanity check in add_packed_git()”
  1. sanity check in add_packed_git()Pavel Roskin, Dec 21, 2005
  2. Junio C HamanoDec 22, 2005
  3. Daniel BarkalowDec 22, 2005
  4. Junio C HamanoDec 22, 2005

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.