Commit a96a87f3 authored by Simon Giesecke's avatar Simon Giesecke

Problem: problematic atoi function is used (CERT ERR-34C)

Solution: use strtol instead
parent 27313774
...@@ -228,7 +228,7 @@ int zmq::tcp_address_mask_t::resolve (const char *name_, bool ipv6_) ...@@ -228,7 +228,7 @@ int zmq::tcp_address_mask_t::resolve (const char *name_, bool ipv6_)
} else if (mask_str == "0") } else if (mask_str == "0")
_address_mask = 0; _address_mask = 0;
else { else {
const int mask = atoi (mask_str.c_str ()); const long mask = strtol (mask_str.c_str (), NULL, 10);
if ((mask < 1) if ((mask < 1)
|| (_network_address.family () == AF_INET6 && mask > full_mask_ipv6) || (_network_address.family () == AF_INET6 && mask > full_mask_ipv6)
|| (_network_address.family () != AF_INET6 || (_network_address.family () != AF_INET6
...@@ -236,7 +236,7 @@ int zmq::tcp_address_mask_t::resolve (const char *name_, bool ipv6_) ...@@ -236,7 +236,7 @@ int zmq::tcp_address_mask_t::resolve (const char *name_, bool ipv6_)
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }
_address_mask = mask; _address_mask = static_cast<int> (mask);
} }
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment