getaddrinfo: Merge IPv6 addresses and IPv4 addresses [BZ #21295]
authorDmitry Bilunov <kmeaw@kmeaw.com>
Sat, 24 Jun 2017 14:49:34 +0000 (16:49 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Sat, 24 Jun 2017 14:50:42 +0000 (16:50 +0200)
ChangeLog
sysdeps/posix/getaddrinfo.c

index 1b4c8dd..eb9eb58 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-06-24  Dmitry Bilunov  <kmeaw@kmeaw.com>
+
+       [BZ #21295]
+       * sysdeps/posix/getaddrinfo.c (convert_hostent_to_gaih_addrtuple):
+       Append addresses at the end of the list.
+
 2017-06-23  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #21666]
index 4ec1796..91e0a76 100644 (file)
@@ -190,16 +190,16 @@ gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp,
 
 /* Convert struct hostent to a list of struct gaih_addrtuple objects.
    h_name is not copied, and the struct hostent object must not be
-   deallocated prematurely.  *RESULT must be NULL or a pointer to an
-   object allocated using malloc, which is freed.  */
+   deallocated prematurely.  *RESULT must be NULL or a pointer to a
+   linked-list.  The new addresses are appended at the end.  */
 static bool
 convert_hostent_to_gaih_addrtuple (const struct addrinfo *req,
                                   int family,
                                   struct hostent *h,
                                   struct gaih_addrtuple **result)
 {
-  free (*result);
-  *result = NULL;
+  while (*result)
+    result = &(*result)->next;
 
   /* Count the number of addresses in h->h_addr_list.  */
   size_t count = 0;