{"thread":{"id":"10005","subject":"[PATCH 3/3] Prevent send-pack from segfaulting when a branch doesn't match","startedAt":"2007-09-25T04:13:25Z","lastAt":"2007-09-25T04:13:25Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"53960","messageId":"20070925041325.GC11363@spearce.org","threadId":"10005","inReplyTo":null,"subject":"[PATCH 3/3] Prevent send-pack from segfaulting when a branch doesn't match","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-09-25T04:13:25Z","receivedAt":"2007-09-25T04:13:25Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"If `git push url foo` can't find a local branch named foo we can't\nmatch it to any remote branch as the local branch is NULL and its\nname is probably at position 0x34 in memory.  On most systems that\nisn't a valid address for git-send-pack's virtual address space\nand we segfault.\n\nIf we can't find a source match and we have no destination we\nneed to abort the match function early before we try to match the\ndestination against the remote.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n remote.c |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex 2166a2b..e7d735b 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -610,8 +610,11 @@ static int match_explicit(struct ref *src, struct ref *dst,\n \tif (!matched_src)\n \t\terrs = 1;\n \n-\tif (!dst_value)\n+\tif (!dst_value) {\n+\t\tif (!matched_src)\n+\t\t\treturn errs;\n \t\tdst_value = matched_src->name;\n+\t}\n \n \tswitch (count_refspec_match(dst_value, dst, &matched_dst)) {\n \tcase 1:\n-- \n1.5.3.2.124.g2456-dirty\n"}]}