Skip to content

Commit 4966c12

Browse files
committed
accept [IPv6] on memcached_servers_parse
1 parent 46bddd2 commit 4966c12

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/libmemcached/parse.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,17 @@ memcached_server_list_st memcached_servers_parse(const char *server_strings) {
4444
begin_ptr = end_ptr;
4545
}
4646

47-
ptr = strchr(buffer, ':');
48-
47+
ptr = strchr(buffer, '[');
48+
if (ptr) {
49+
ptr2 = strchr(ptr+1, ']');
50+
}
51+
if (ptr && ptr2) {
52+
// [IPv6]:port
53+
ptr = strchr(ptr2+1, ':');
54+
} else {
55+
// IPv4:port or name:port
56+
ptr = strchr(buffer, ':');
57+
}
4958
in_port_t port = 0;
5059
if (ptr) {
5160
ptr[0] = 0;

0 commit comments

Comments
 (0)