tcp_address: make port number conversion more robust

This still rejects 00 as port number.
This commit is contained in:
Martin Hurton 2012-03-27 06:45:03 +02:00
parent c428f6aece
commit 700e08c3c2

View File

@ -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) {