about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-08-14 08:49:55 +0000
committerUlrich Drepper <drepper@redhat.com>2004-08-14 08:49:55 +0000
commit862275809d077373fe5cc6b906928780fe1a1b6e (patch)
treeb3824b77382648c8538a6b3d3a9ad1d3678cd961
parent913e79f5da4cac6754a29068086a9cb7aa3508b1 (diff)
downloadglibc-862275809d077373fe5cc6b906928780fe1a1b6e.tar.gz
glibc-862275809d077373fe5cc6b906928780fe1a1b6e.tar.xz
glibc-862275809d077373fe5cc6b906928780fe1a1b6e.zip
(gaih_inet): Really set ai_canonname only in one entry.
-rw-r--r--sysdeps/posix/getaddrinfo.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index a2972b1bca..ef32e68f01 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -664,7 +664,8 @@ gaih_inet (const char *name, const struct gaih_service *service,
 		}
 	      else
 		no_more = __nss_database_lookup ("hosts", NULL,
-						 "dns [!UNAVAIL=return] files", &nip);
+						 "dns [!UNAVAIL=return] files",
+						 &nip);
 
 	      if (__res_maybe_init (&_res, 0) == -1)
 		no_more = 1;
@@ -939,11 +940,14 @@ gaih_inet (const char *name, const struct gaih_service *service,
 		memset (sinp->sin_zero, '\0', sizeof (sinp->sin_zero));
 	      }
 
-	    if (c)
+	    if (namelen != 0)
 	      {
 		(*pai)->ai_canonname = ((void *) (*pai) +
 					sizeof (struct addrinfo) + socklen);
 		strcpy ((*pai)->ai_canonname, c);
+
+		/* We do not need to allocate the canonical name anymore.  */
+		namelen = 0;
 	      }
 	    else
 	      (*pai)->ai_canonname = NULL;