From 48bc2fb0cd9ca05005c2062c3493e62e13593f55 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 15 Oct 2005 17:10:14 -0700 Subject: 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 --- clone-pack.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'clone-pack.c') diff --git a/clone-pack.c b/clone-pack.c index c102ca885..48bee96a8 100644 --- a/clone-pack.c +++ b/clone-pack.c @@ -34,6 +34,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); -- cgit v1.2.1