From 58c067ff0e0dbd009b8afbf2f17615102cc5500d Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Wed, 25 Jun 2014 14:36:55 +0200 Subject: [PATCH 1/2] Revert "Problem: tcp_address.cpp allowed [ and ] around address" This reverts commit 78a7b469a1993b681031f513d0c750c3a8454bb8. --- src/tcp_address.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tcp_address.cpp b/src/tcp_address.cpp index e9b2b3e3..fc20386d 100644 --- a/src/tcp_address.cpp +++ b/src/tcp_address.cpp @@ -413,6 +413,11 @@ int zmq::tcp_address_t::resolve (const char *name_, bool local_, bool ipv6_, boo std::string addr_str (name_, delimiter - name_); std::string port_str (delimiter + 1); + // Remove square brackets around the address, if any. + if (addr_str.size () >= 2 && addr_str [0] == '[' && + addr_str [addr_str.size () - 1] == ']') + addr_str = addr_str.substr (1, addr_str.size () - 2); + // Allow 0 specifically, to detect invalid port error in atoi if not uint16_t port; if (port_str == "*" || port_str == "0") From 6e91330a0cb18f8ac2d87151ad084d196481147e Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Wed, 25 Jun 2014 14:37:54 +0200 Subject: [PATCH 2/2] Added clarifying comment --- src/tcp_address.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tcp_address.cpp b/src/tcp_address.cpp index fc20386d..ef8b7954 100644 --- a/src/tcp_address.cpp +++ b/src/tcp_address.cpp @@ -413,7 +413,7 @@ int zmq::tcp_address_t::resolve (const char *name_, bool local_, bool ipv6_, boo std::string addr_str (name_, delimiter - name_); std::string port_str (delimiter + 1); - // Remove square brackets around the address, if any. + // Remove square brackets around the address, if any, as used in IPv6 if (addr_str.size () >= 2 && addr_str [0] == '[' && addr_str [addr_str.size () - 1] == ']') addr_str = addr_str.substr (1, addr_str.size () - 2);