git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 3/3] Prevent send-pack from segfaulting when a branch doesn't match
@ 2007-09-25  4:13 Shawn O. Pearce
  0 siblings, 0 replies; only message in thread
From: Shawn O. Pearce @ 2007-09-25  4:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

If `git push url foo` can't find a local branch named foo we can't
match it to any remote branch as the local branch is NULL and its
name is probably at position 0x34 in memory.  On most systems that
isn't a valid address for git-send-pack's virtual address space
and we segfault.

If we can't find a source match and we have no destination we
need to abort the match function early before we try to match the
destination against the remote.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 remote.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/remote.c b/remote.c
index 2166a2b..e7d735b 100644
--- a/remote.c
+++ b/remote.c
@@ -610,8 +610,11 @@ static int match_explicit(struct ref *src, struct ref *dst,
 	if (!matched_src)
 		errs = 1;
 
-	if (!dst_value)
+	if (!dst_value) {
+		if (!matched_src)
+			return errs;
 		dst_value = matched_src->name;
+	}
 
 	switch (count_refspec_match(dst_value, dst, &matched_dst)) {
 	case 1:
-- 
1.5.3.2.124.g2456-dirty

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-09-25  4:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-25  4:13 [PATCH 3/3] Prevent send-pack from segfaulting when a branch doesn't match Shawn O. Pearce

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).