Problem: invalid address results in out-of-range string access

Solution: check for zone string length before using it in ip_resolver
It turns out std::string::at does not check for string length before
dereferencing
This commit is contained in:
Luca Boccassi 2020-05-16 13:40:29 +01:00
parent 3033112645
commit dccf1723cc

View File

@ -252,6 +252,10 @@ int zmq::ip_resolver_t::resolve (ip_addr_t *ip_addr_, const char *name_)
if (pos != std::string::npos) {
std::string if_str = addr.substr (pos + 1);
if (if_str.empty ()) {
errno = EINVAL;
return -1;
}
addr = addr.substr (0, pos);
if (isalpha (if_str.at (0))) {