From 700e08c3c278b5ac67985404ab3e97a608bbf2fd Mon Sep 17 00:00:00 2001 From: Martin Hurton Date: Tue, 27 Mar 2012 06:45:03 +0200 Subject: [PATCH] tcp_address: make port number conversion more robust This still rejects 00 as port number. --- src/tcp_address.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tcp_address.cpp b/src/tcp_address.cpp index 46a2e36d..7db3d248 100644 --- a/src/tcp_address.cpp +++ b/src/tcp_address.cpp @@ -392,10 +392,10 @@ int zmq::tcp_address_t::resolve (const char *name_, bool local_, bool ipv4only_) uint16_t port; // Allow 0 specifically, to detect invalid port error in atoi if not - if (port_str[0] == '*' || port_str[0] == '0') { + if (port_str == "*" || port_str == "0") // Resolve wildcard to 0 to allow autoselection of port port = 0; - } else { + else { // Parse the port number (0 is not a valid port). port = (uint16_t) atoi (port_str.c_str()); if (port == 0) {