IPv6Address::to_string() return a local address
LubinLew opened this issue · 1 comments
LubinLew commented
Function return a local address (buffer
), Is this correct?
string IPv6Address::to_string() const {
char buffer[INET6_ADDRSTRLEN];
#ifdef _WIN32
// mingw on linux somehow doesn't have InetNtop
#ifdef _MSC_VER
if (InetNtopA(AF_INET6, (PVOID)address_, buffer, sizeof(buffer)) == 0) {
throw invalid_address();
}
#else
ULONG sz = sizeof(buffer);
if (RtlIpv6AddressToStringExA((const IN6_ADDR*)address_, 0, 0, buffer, &sz) != NO_ERROR) {
throw invalid_address();
}
#endif
#else
if (inet_ntop(AF_INET6, address_, buffer, sizeof(buffer)) == 0) {
throw invalid_address();
}
#endif
return buffer;
}
LubinLew commented
return std::string