summaryrefslogtreecommitdiff
path: root/daemon.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-01-27 14:56:42 -0800
committerJunio C Hamano <gitster@pobox.com>2010-01-27 14:56:42 -0800
commit68186857a9bb0a71e9456155623e02d398a5b817 (patch)
treea8c9a2b0a6d27f15739cb357850d9f5fb72125f7 /daemon.c
parenta0075d9e6ae211e8bde3eb40c8cdebb1772ee680 (diff)
parent9aa5053d9ffc7fade885b58a34175b4907b1a4f8 (diff)
downloadgit-68186857a9bb0a71e9456155623e02d398a5b817.tar.gz
Merge branch 'il/maint-colon-address'
* il/maint-colon-address: Allow use of []-wrapped addresses in git:// Support addresses with ':' in git-daemon
Diffstat (limited to 'daemon.c')
-rw-r--r--daemon.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/daemon.c b/daemon.c
index 360635eb1c..6c2bd97713 100644
--- a/daemon.c
+++ b/daemon.c
@@ -399,6 +399,33 @@ static char *xstrdup_tolower(const char *str)
return dup;
}
+static void parse_host_and_port(char *hostport, char **host,
+ char **port)
+{
+ if (*hostport == '[') {
+ char *end;
+
+ end = strchr(hostport, ']');
+ if (!end)
+ die("Invalid reqeuest ('[' without ']')");
+ *end = '\0';
+ *host = hostport + 1;
+ if (!end[1])
+ *port = NULL;
+ else if (end[1] == ':')
+ *port = end + 2;
+ else
+ die("Garbage after end of host part");
+ } else {
+ *host = hostport;
+ *port = strrchr(hostport, ':');
+ if (*port) {
+ *port = '\0';
+ ++*port;
+ }
+ }
+}
+
/*
* Read the host as supplied by the client connection.
*/
@@ -415,11 +442,10 @@ static void parse_host_arg(char *extra_args, int buflen)
vallen = strlen(val) + 1;
if (*val) {
/* Split <host>:<port> at colon. */
- char *host = val;
- char *port = strrchr(host, ':');
+ char *host;
+ char *port;
+ parse_host_and_port(val, &host, &port);
if (port) {
- *port = 0;
- port++;
free(tcp_port);
tcp_port = xstrdup(port);
}