summaryrefslogtreecommitdiff
path: root/send-pack.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-12-13 18:30:11 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-12-13 18:30:11 (GMT)
commit37adac765a469f8f8495e2befe7afeda65a2b272 (patch)
tree2a9b96df44e37a717ee01a782c120d3ef089417a /send-pack.c
parent411fb8baa6862b76f7bdd9fc0d5844855a4db589 (diff)
downloadgit-37adac765a469f8f8495e2befe7afeda65a2b272.zip
git-37adac765a469f8f8495e2befe7afeda65a2b272.tar.gz
git-37adac765a469f8f8495e2befe7afeda65a2b272.tar.bz2
send-pack: tighten checks for remote names
"git push $URL HEAD~6" created a bogus ref HEAD~6 immediately under $GIT_DIR of the remote repository. While we should keep refspecs that have arbitrary extended SHA-1 expression on the source side working (e.g. "HEAD~6:refs/tags/yesterday"), we should not create bogus ref on the other end. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'send-pack.c')
-rw-r--r--send-pack.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/send-pack.c b/send-pack.c
index 328dbbc..cc884f3 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -406,6 +406,25 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
return ret;
}
+static void verify_remote_names(int nr_heads, char **heads)
+{
+ int i;
+
+ for (i = 0; i < nr_heads; i++) {
+ const char *remote = strchr(heads[i], ':');
+
+ remote = remote ? (remote + 1) : heads[i];
+ switch (check_ref_format(remote)) {
+ case 0: /* ok */
+ case -2: /* ok but a single level -- that is fine for
+ * a match pattern.
+ */
+ continue;
+ }
+ die("remote part of refspec is not a valid name in %s",
+ heads[i]);
+ }
+}
int main(int argc, char **argv)
{
@@ -457,6 +476,8 @@ int main(int argc, char **argv)
usage(send_pack_usage);
if (heads && send_all)
usage(send_pack_usage);
+ verify_remote_names(nr_heads, heads);
+
pid = git_connect(fd, dest, exec);
if (pid < 0)
return 1;