From: Sebastian Harl Date: Sun, 1 Feb 2015 16:04:09 +0000 (+0100) Subject: frontend, client: Properly support IPv6 when handling address strings. X-Git-Tag: sysdb-0.7.0~17 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f57b23c4059c67c4c2c7ab1b06c02c000bcf7250;p=sysdb.git frontend, client: Properly support IPv6 when handling address strings. --- diff --git a/src/client/sock.c b/src/client/sock.c index 838dd95..b1efe58 100644 --- a/src/client/sock.c +++ b/src/client/sock.c @@ -187,7 +187,7 @@ connect_tcp(sdb_client_t *client, const char *address) } strncpy(host, address, sizeof(host)); - if ((tmp = strchr(host, (int)':'))) + if ((tmp = strrchr(host, (int)':'))) *tmp = '\0'; if (! host[0]) strncpy(host, "localhost", sizeof(host)); diff --git a/src/frontend/sock.c b/src/frontend/sock.c index c2a805a..cf187fc 100644 --- a/src/frontend/sock.c +++ b/src/frontend/sock.c @@ -434,7 +434,8 @@ get_type(const char *address) return impl->type; } } - return -1; + /* don't report an error, this could be an IPv6 address */ + return listener_impls[0].type; } /* get_type */ static void diff --git a/src/utils/os.c b/src/utils/os.c index c94e271..2b6a514 100644 --- a/src/utils/os.c +++ b/src/utils/os.c @@ -319,7 +319,7 @@ sdb_resolve(int network, const char *address, struct addrinfo **res) if (address) { host = address; - port = strchr(host, ':'); + port = strrchr(host, ':'); if (port) { *port = '\0'; ++port;