Skip to content

Commit b112b14

Browse files
jiangxingitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 282616c commit b112b14

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
514514
return "deletion prohibited";
515515
}
516516

517-
if (!strcmp(namespaced_name, head_name)) {
517+
if (head_name && !strcmp(namespaced_name, head_name)) {
518518
switch (deny_delete_current) {
519519
case DENY_IGNORE:
520520
break;

0 commit comments

Comments
 (0)