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>
This commit is contained in:
Junio C Hamano
2005-10-15 17:10:14 -07:00
parent 652d5dc6c0
commit 48bc2fb0cd
3 changed files with 16 additions and 0 deletions

View File

@ -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);