@matheusbsbs / matheus-bagliano / commits / 4491e62ae9
Fork 0

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>

Shawn O. Pearce committed Sep 25, 2007 at 00:13 UTC 4491e62ae932d5774f628d1bd3be663c11058a73
1 file changed +4 -1
remote.c
+4 -1
@@ -610,8 +610,11 @@ static int match_explicit(struct ref *src, struct ref *dst,
610 if (!matched_src)
611 errs = 1;
612
613 - if (!dst_value)
613 + if (!dst_value) {
614 + if (!matched_src)
615 + return errs;
616 dst_value = matched_src->name;
617 + }
618
619 switch (count_refspec_match(dst_value, dst, &matched_dst)) {
620 case 1: