Code

frontend, client: Properly support IPv6 when handling address strings.
authorSebastian Harl <sh@tokkee.org>
Sun, 1 Feb 2015 16:04:09 +0000 (17:04 +0100)
committerSebastian Harl <sh@tokkee.org>
Sun, 1 Feb 2015 16:04:09 +0000 (17:04 +0100)
src/client/sock.c
src/frontend/sock.c
src/utils/os.c

index 838dd95d880debea45d0549c5fde06be776308c1..b1efe58e189700fd46c7b77b46c55278c39a150d 100644 (file)
@@ -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));
index c2a805aa2510fbe168f4e706b52acfec804dabc7..cf187fcb42adc4bffc229f6c20ed208105c9bde5 100644 (file)
@@ -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
index c94e271be545dfe1bf51ec70d34887fc73ff3a19..2b6a51460a67f89122dbee5ec7d75d70e2b3fe82 100644 (file)
@@ -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;