git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sanity check in add_packed_git()
@ 2005-12-21 23:47 Pavel Roskin
  2005-12-22  1:42 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Pavel Roskin @ 2005-12-21 23:47 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-12-22  9:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-21 23:47 [PATCH] sanity check in add_packed_git() Pavel Roskin
2005-12-22  1:42 ` Junio C Hamano
2005-12-22  1:58   ` Daniel Barkalow
2005-12-22  9:39     ` Junio C Hamano

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 NNTP newsgroup(s).