mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-21 15:12:03 +08:00
tcp_address: check address length before manipulating it
This commit is contained in:
parent
19f364e202
commit
c428f6aece
@ -386,7 +386,7 @@ int zmq::tcp_address_t::resolve (const char *name_, bool local_, bool ipv4only_)
|
|||||||
std::string port_str (delimiter + 1);
|
std::string port_str (delimiter + 1);
|
||||||
|
|
||||||
// Remove square brackets around the address, if any.
|
// Remove square brackets around the address, if any.
|
||||||
if (!addr_str.empty () && addr_str [0] == '[' &&
|
if (addr_str.size () >= 2 && addr_str [0] == '[' &&
|
||||||
addr_str [addr_str.size () - 1] == ']')
|
addr_str [addr_str.size () - 1] == ']')
|
||||||
addr_str = addr_str.substr (1, addr_str.size () - 2);
|
addr_str = addr_str.substr (1, addr_str.size () - 2);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user