Commit 27262cba authored by aligungr's avatar aligungr

IP resolution bug fix

parent f74badf4
...@@ -32,15 +32,9 @@ static std::string OctetStringToIpString(const OctetString &address) ...@@ -32,15 +32,9 @@ static std::string OctetStringToIpString(const OctetString &address)
char str[INET6_ADDRSTRLEN] = {0}; char str[INET6_ADDRSTRLEN] = {0};
if (domain == AF_INET) if (domain == AF_INET)
{ std::memcpy(buf, address.data(), 4);
auto *p = reinterpret_cast<in_addr *>(buf);
p->s_addr = (in_addr_t)octet4{address.data()[0], address.data()[1], address.data()[2], address.data()[3]};
}
else else
{ std::memcpy(buf, address.data(), 16);
auto *p = reinterpret_cast<in6_addr *>(buf);
std::memcpy(p, address.data(), 16);
}
if (inet_ntop(domain, buf, str, INET6_ADDRSTRLEN) == nullptr) if (inet_ntop(domain, buf, str, INET6_ADDRSTRLEN) == nullptr)
throw LibError("Bad Inet address, inet_ntop failure:", errno); throw LibError("Bad Inet address, inet_ntop failure:", errno);
......
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