From e2cc0bee118d7a282bdce0b71db433def3022fb6 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 8 Apr 2011 08:14:28 -0400 Subject: [PATCH] return the requested string as the "canonical name" for numeric addresses previously NULL was returned in ai_canonname, resulting in crashes in some callers. this behavior was incorrect. note however that the new behavior differs from glibc, which performs reverse dns lookups. POSIX is very clear that a reverse DNS lookup must not be performed for numeric addresses. --- src/network/getaddrinfo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c index 8126236b..c0f135f3 100644 --- a/src/network/getaddrinfo.c +++ b/src/network/getaddrinfo.c @@ -117,6 +117,7 @@ int getaddrinfo(const char *host, const char *serv, const struct addrinfo *hint, buf->ai.ai_addr = (void *)&buf->sa; buf->ai.ai_addrlen = family==AF_INET6 ? sizeof sa.sin6 : sizeof sa.sin; buf->ai.ai_family = family; + buf->ai.ai_canonname = (char *)host; buf->sa = sa; buf->sa.sin.sin_port = port; *res = &buf->ai; -- 2.25.1