summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-04-08 08:14:28 -0400
committerRich Felker <dalias@aerifal.cx>2011-04-08 08:14:28 -0400
commite2cc0bee118d7a282bdce0b71db433def3022fb6 (patch)
treea639415206c52ca1dcbe9eca03bc3c610bce026b
parentd4fbebe18d2d063069b1505d357a1ff3b5ca0ab8 (diff)
downloadmusl-e2cc0bee118d7a282bdce0b71db433def3022fb6.tar.gz
musl-e2cc0bee118d7a282bdce0b71db433def3022fb6.tar.bz2
musl-e2cc0bee118d7a282bdce0b71db433def3022fb6.tar.xz
musl-e2cc0bee118d7a282bdce0b71db433def3022fb6.zip
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.
-rw-r--r--src/network/getaddrinfo.c1
1 files changed, 1 insertions, 0 deletions
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;