aboutsummaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-09-25 00:13:25 -0400
committerJunio C Hamano <gitster@pobox.com>2007-09-24 23:25:26 -0700
commit4491e62ae932d5774f628d1bd3be663c11058a73 (patch)
tree4a47cf0b2da34de6a673703e388dadd3442c1a6b /remote.c
parent7dfee372b08f653c2709c90bea986e4ed608f410 (diff)
downloadgit-4491e62ae932d5774f628d1bd3be663c11058a73.tar.gz
git-4491e62ae932d5774f628d1bd3be663c11058a73.tar.xz
Prevent send-pack from segfaulting when a branch doesn't match
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/remote.c b/remote.c
index 2166a2bf1..e7d735b98 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: