提交 e8dbd76d 编写于 作者: I Ilari Liusvaara 提交者: Junio C Hamano

Support addresses with ':' in git-daemon

If host address could have ':' in it (e.g. numeric IPv6 address), then
host and port could not be uniquely parsed. Fix this by parsing the
"["<host>"]":<port> and "["<host>"]" notations. Currently the built-in
git:// client would send <host>:<port> or <host> for such thing, but
it doesn't matter as due to bugs, resolving address fails if <host>
contains ':'.
Signed-off-by: NIlari Liusvaara <ilari.liusvaara@elisanet.fi>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 35eabd15
......@@ -445,6 +445,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.
*/
......@@ -461,11 +488,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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册