[Bug network/14990] getaddrinfo with servname=NULL returns duplicate addresses

psimerda at redhat dot com sourceware-bugzilla@sourceware.org
Fri Jan 11 15:58:00 GMT 2013


http://sourceware.org/bugzilla/show_bug.cgi?id=14990

--- Comment #2 from Pavel Šimerda <psimerda at redhat dot com> 2013-01-11 15:58:28 UTC ---
The code for #3a could look something like this:

  if (!servname)
    {
      /* POSIX1-2008: If servname is null, the call shall return network-level
       * addresses for the specified nodename.
       *
       * Example:
       *
       * getaddrinfo ("localhost", NULL, ...) ->
       *   family=AF_INET6 socktype=0 protocol=0 address=::1 port=0
       *   family=AF_INET socktype=0 protocol=0 address=127.0.0.1 port=0
       */
      struct gaih_servtuple *st = malloc (sizeof (struct gaih_servtuple));
      st->next = NULL;
      st->port = 0;
      /* Copy socktype and protocol from the request. This maintains backwards
       * compatibility. Callers should not set socktype and protocol when
       * service is NULL.
       */
      st->socktype = socktype;
      st->protocol = protocol;

      *servtuple = st;
      return 0;
    }

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the Glibc-bugs mailing list