summaryrefslogtreecommitdiff
path: root/builtin/receive-pack.c
diff options
context:
space:
mode:
authorJiang Xin <worldhello.net@gmail.com>2015-07-22 01:49:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-07-22 21:18:22 (GMT)
commitb112b14d7869bf3c000abb84cd22e57dd811d031 (patch)
tree8ae07a38f729524bad1bbb4a932e4fa37a50a2dc /builtin/receive-pack.c
parent282616c72d1d08a77ca4fe1186cb708c38408d87 (diff)
downloadgit-b112b14d7869bf3c000abb84cd22e57dd811d031.zip
git-b112b14d7869bf3c000abb84cd22e57dd811d031.tar.gz
git-b112b14d7869bf3c000abb84cd22e57dd811d031.tar.bz2
receive-pack: crash when checking with non-exist HEAD
If HEAD of a repository points to a conflict reference, such as: * There exist a reference named 'refs/heads/jx/feature1', but HEAD points to 'refs/heads/jx', or * There exist a reference named 'refs/heads/feature', but HEAD points to 'refs/heads/feature/bad'. When we push to delete a reference for this repo, such as: git push /path/to/bad-head-repo.git :some/good/reference The git-receive-pack process will crash. This is because if HEAD points to a conflict reference, the function `resolve_refdup("HEAD", ...)` does not return a valid reference name, but a null buffer. Later matching the delete reference against the null buffer will cause git-receive-pack crash. Signed-off-by: Jiang Xin <worldhello.net@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/receive-pack.c')
-rw-r--r--builtin/receive-pack.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index c323081..2380127 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -514,7 +514,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
return "deletion prohibited";
}
- if (!strcmp(namespaced_name, head_name)) {
+ if (head_name && !strcmp(namespaced_name, head_name)) {
switch (deny_delete_current) {
case DENY_IGNORE:
break;