about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-05-24 08:18:43 +0000
committerUlrich Drepper <drepper@redhat.com>1999-05-24 08:18:43 +0000
commitcb293d6692bb3b305726b5e579753342cf71d192 (patch)
tree5fb406b98ec60114b88a6ba66624c2491ab7365a
parentad4637185356034cfe2f8c7a2c547d2311b502bc (diff)
downloadglibc-cb293d6692bb3b305726b5e579753342cf71d192.tar.gz
glibc-cb293d6692bb3b305726b5e579753342cf71d192.tar.xz
glibc-cb293d6692bb3b305726b5e579753342cf71d192.zip
(gaih_inet): Set socket address to loopback if no name is given and AI_PASSIVE is not set.
-rw-r--r--sysdeps/posix/getaddrinfo.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index f43aa03d1f..7217e5de3e 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -383,6 +383,14 @@ gaih_inet (const char *name, const struct gaih_service *service,
 
       memset (at->next, 0, sizeof(struct gaih_addrtuple));
       at->next->family = AF_INET;
+
+      if (!(req->ai_flags & AI_PASSIVE))
+	{
+	  /* RFC 2553 requires to set set the socket address structure
+	     to the loopback address in this case.  */
+	  memcpy (at->addr, &in6addr_loopback, sizeof (struct in6_addr));
+	  ((struct in_addr *)at->next->addr)->s_addr = htonl (INADDR_LOOPBACK);
+	}
     }
 
   if (pai == NULL)