summaryrefslogtreecommitdiff
path: root/clone-pack.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-10-13 18:57:39 -0700
committerJunio C Hamano <junkio@cox.net>2005-10-15 11:23:39 -0700
commitd8a1deecc6ef37728b951eaba051deb7e0a38af8 (patch)
tree46880218861d52fb0c30d520030a70cd32bca163 /clone-pack.c
parent03feddd6e8e779086ac2d131ded325f8e5601653 (diff)
downloadgit-d8a1deecc6ef37728b951eaba051deb7e0a38af8.tar.gz
Refuse to create funny refs in clone-pack, git-fetch and receive-pack.
Using git-check-ref-format, make sure we do not create refs with funny names when cloning from elsewhere (clone-pack), fast forwarding local heads (git-fetch), or somebody pushes into us (receive-pack). Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'clone-pack.c')
-rw-r--r--clone-pack.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/clone-pack.c b/clone-pack.c
index 9a3371e1b2..0ea7e7f65d 100644
--- a/clone-pack.c
+++ b/clone-pack.c
@@ -36,6 +36,12 @@ static void write_one_ref(struct ref *ref)
int fd;
char *hex;
+ if (!strncmp(ref->name, "refs/", 5) &&
+ check_ref_format(ref->name + 5)) {
+ error("refusing to create funny ref '%s' locally", ref->name);
+ return;
+ }
+
if (safe_create_leading_directories(path))
die("unable to create leading directory for %s", ref->name);
fd = open(path, O_CREAT | O_EXCL | O_WRONLY, 0666);