From 98ddf1679bde57876881eb5bb24d6364f31dab1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 14 Aug 2019 17:09:24 +0300 Subject: [PATCH] Fix name resolution The ai_addr must be cast into sockaddr_in6 and the sin6_addr member must be passed to inet_ntop. --- maxutils/maxbase/src/host.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maxutils/maxbase/src/host.cc b/maxutils/maxbase/src/host.cc index 33a439601..f8f12f622 100644 --- a/maxutils/maxbase/src/host.cc +++ b/maxutils/maxbase/src/host.cc @@ -250,7 +250,9 @@ bool name_lookup(const std::string& host, std::string* addr_out, std::string* er { // getaddrinfo may return multiple result addresses. Only consider the first. char buf[INET6_ADDRSTRLEN]; - if (inet_ntop(AF_INET6, results->ai_addr, buf, sizeof(buf))) + in6_addr* addr = &((sockaddr_in6*)results->ai_addr)->sin6_addr; + + if (inet_ntop(AF_INET6, addr, buf, sizeof(buf))) { *addr_out = buf; success = true;