提交 4491e62a 编写于 作者: S Shawn O. Pearce 提交者: Junio C Hamano

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: NShawn O. Pearce <spearce@spearce.org>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 7dfee372
......@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册