git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fetch-pack: check for valid commit from server
@ 2011-08-18 13:36 Nguyễn Thái Ngọc Duy
  2011-08-18 21:32 ` Shawn Pearce
  2011-08-19 15:11 ` Nguyễn Thái Ngọc Duy
  0 siblings, 2 replies; 5+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2011-08-18 13:36 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

A malicious server can return ACK with non-existent SHA-1 or not a
commit. lookup_commit() in this case may return NULL. Do not let
fetch-pack crash by accessing NULL address in this case.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
  However it raises another question, what if the other end returns a
  valid commit, but not the one in "have" line fetch-pack sent? Are we
  OK with that?

 builtin/fetch-pack.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 4367984..3c871c2 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -395,6 +395,8 @@ static int find_common(int fd[2], unsigned char *result_sha1,
 				case ACK_continue: {
 					struct commit *commit =
 						lookup_commit(result_sha1);
+					if (!commit)
+						die("invalid commit %s", sha1_to_hex(result_sha1));
 					if (args.stateless_rpc
 					 && ack == ACK_common
 					 && !(commit->object.flags & COMMON)) {
-- 
1.7.4.74.g639db

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

end of thread, other threads:[~2011-08-19 20:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-18 13:36 [PATCH] fetch-pack: check for valid commit from server Nguyễn Thái Ngọc Duy
2011-08-18 21:32 ` Shawn Pearce
2011-08-19  4:19   ` Nguyen Thai Ngoc Duy
2011-08-19 15:11 ` Nguyễn Thái Ngọc Duy
2011-08-19 20:18   ` 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).