summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 03feddd)
raw | patch | inline | side by side (parent: 03feddd)
author | Junio C Hamano <junkio@cox.net> | |
Fri, 14 Oct 2005 01:57:39 +0000 (18:57 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 15 Oct 2005 18:23:39 +0000 (11:23 -0700) |
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>
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>
clone-pack.c | patch | blob | history | |
git-parse-remote.sh | patch | blob | history | |
receive-pack.c | patch | blob | history |
diff --git a/clone-pack.c b/clone-pack.c
index 9a3371e1b2d71fb2e767363ad24ca20f17955ed2..0ea7e7f65deaa41847bf5c8a1a5e812a09d4acf2 100644 (file)
--- a/clone-pack.c
+++ b/clone-pack.c
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);
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 5e75e15a7e57ce0783ec4a9731e0c65563fd1198..aea7b0e5497fb0727533ea750503193fe308374a 100755 (executable)
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
heads/* | tags/* ) local="refs/$local" ;;
*) local="refs/heads/$local" ;;
esac
+
+ if local_ref_name=$(expr "$local" : 'refs/\(.*\)')
+ then
+ git-check-ref-format "$local_ref_name" ||
+ die "* refusing to create funny ref '$local_ref_name' locally"
+ fi
echo "${dot_prefix}${force}${remote}:${local}"
dot_prefix=.
done
diff --git a/receive-pack.c b/receive-pack.c
index 06857eb77fef93788f54d17cca68924f5213c9db..8f157bc3f0ef1f9d96bca18fc81854fc24bff936 100644 (file)
--- a/receive-pack.c
+++ b/receive-pack.c
char new_hex[60], *old_hex, *lock_name;
int newfd, namelen, written;
+ if (!strncmp(name, "refs/", 5) && check_ref_format(name + 5))
+ return error("refusing to create funny ref '%s' locally",
+ name);
+
namelen = strlen(name);
lock_name = xmalloc(namelen + 10);
memcpy(lock_name, name, namelen);