about summary refs log tree commit diff
path: root/sysdeps/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-08-14 20:13:23 +0000
committerUlrich Drepper <drepper@redhat.com>2004-08-14 20:13:23 +0000
commitc7fa647a109ef0e44faffe7675df1a1ab9afede0 (patch)
tree918a0ba148702b8af89994352a8749446cdce55a /sysdeps/posix
parent97306b0b34c31731534771e701620e61c1549670 (diff)
downloadglibc-c7fa647a109ef0e44faffe7675df1a1ab9afede0.tar.gz
glibc-c7fa647a109ef0e44faffe7675df1a1ab9afede0.tar.xz
glibc-c7fa647a109ef0e44faffe7675df1a1ab9afede0.zip
Update.
	* sysdeps/posix/getaddrinfo.c (getaddrinfo): I rfc3484 sorting is
	performed, make sure it is still the first entry after sotring
	which has the ai_canonname information.
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/getaddrinfo.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index ef32e68f01..bdfdcfbcad 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -1437,6 +1437,7 @@ getaddrinfo (const char *name, const char *service,
       /* Sort results according to RFC 3484.  */
       struct sort_result results[nresults];
       struct addrinfo *q;
+      char *canonname = NULL;
 
       for (i = 0, q = p; q != NULL; ++i, q = q->ai_next)
 	{
@@ -1459,6 +1460,14 @@ getaddrinfo (const char *name, const char *service,
 
 	      close_not_cancel_no_status (fd);
 	    }
+
+	  /* Remember the canonical name.  */
+	  if (q->ai_canonname != NULL)
+	    {
+	      assert (canonname == NULL);
+	      canonname = q->ai_canonname;
+	      q->ai_canonname = NULL;
+	    }
 	}
 
       /* We got all the source addresses we can get, now sort using
@@ -1470,6 +1479,9 @@ getaddrinfo (const char *name, const char *service,
       for (i = 1; i < nresults; ++i)
 	q = q->ai_next = results[i].dest_addr;
       q->ai_next = NULL;
+
+      /* Fill in the canonical name into the new first entry.  */
+      p->ai_canonname = canonname;
     }
 
   if (p)