From 4966c12cc51f6ab1658e705bded146f8fd872b27 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 26 Jan 2021 14:34:18 +0100 Subject: [PATCH] accept [IPv6] on memcached_servers_parse --- src/libmemcached/parse.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libmemcached/parse.cc b/src/libmemcached/parse.cc index 12431222..5bf6fac2 100644 --- a/src/libmemcached/parse.cc +++ b/src/libmemcached/parse.cc @@ -44,8 +44,17 @@ memcached_server_list_st memcached_servers_parse(const char *server_strings) { begin_ptr = end_ptr; } - ptr = strchr(buffer, ':'); - + ptr = strchr(buffer, '['); + if (ptr) { + ptr2 = strchr(ptr+1, ']'); + } + if (ptr && ptr2) { + // [IPv6]:port + ptr = strchr(ptr2+1, ':'); + } else { + // IPv4:port or name:port + ptr = strchr(buffer, ':'); + } in_port_t port = 0; if (ptr) { ptr[0] = 0; -- 2.30.2