fix(net): buffer overflow when gathering ipv6 addr

This commit is contained in:
patrick96
2018-11-17 14:31:28 +01:00
parent e582776c84
commit 4c9d4fbe8d

View File

@ -84,7 +84,7 @@ namespace net {
break;
case AF_INET6:
char ip6_buffer[INET_ADDRSTRLEN];
char ip6_buffer[INET6_ADDRSTRLEN];
sa6 = reinterpret_cast<decltype(sa6)>(ifa->ifa_addr);
if (IN6_IS_ADDR_LINKLOCAL(&sa6->sin6_addr)) {
continue;
@ -96,7 +96,7 @@ namespace net {
/* Skip Unique Local Addresses (fc00::/7) */
continue;
}
if (inet_ntop(AF_INET6, &sa6->sin6_addr, ip6_buffer, NI_MAXHOST) == 0) {
if (inet_ntop(AF_INET6, &sa6->sin6_addr, ip6_buffer, INET6_ADDRSTRLEN) == 0) {
m_log.warn("inet_ntop() " + string(strerror(errno)));
continue;
}