about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-06-02 16:35:13 +0200
committerFlorian Weimer <fweimer@redhat.com>2018-01-04 11:20:07 +0100
commit8fbf5688edbaead49130b0d2f887335475a298e7 (patch)
tree839cba016701c982106a4f0ddb81394a34435562
parent1f60575f88769d09c478caa2968b751bca6a90e3 (diff)
downloadglibc-8fbf5688edbaead49130b0d2f887335475a298e7.tar.gz
glibc-8fbf5688edbaead49130b0d2f887335475a298e7.tar.xz
glibc-8fbf5688edbaead49130b0d2f887335475a298e7.zip
getaddrinfo: Fix localplt failure involving strdup
(cherry picked from commit 6257fcfd58479f6b7ae0fdde045b9ff144d543da)
-rw-r--r--ChangeLog6
-rw-r--r--sysdeps/posix/getaddrinfo.c15
2 files changed, 17 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 6d44c42277..2753fdd595 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2017-06-02  Florian Weimer  <fweimer@redhat.com>
 
+	* sysdeps/posix/getaddrinfo.c (gethosts): Eliminate another
+	strdupa.
+	(getcanonname): Use __strdup instead of strdup.
+
+2017-06-02  Florian Weimer  <fweimer@redhat.com>
+
 	* sysdeps/posix/getaddrinfo.c (getcanonname): New function.
 	(gaih_inet): Remove malloc_canonbuf variable.  Call getcanonname.
 
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 4ca1641756..37e84c1eb1 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -286,9 +286,16 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req,
 	}								      \
       *pat = addrmem;							      \
 									      \
-      if (localcanon !=	NULL && canon == NULL)				      \
-	canon = strdupa (localcanon);					      \
-									      \
+      if (localcanon != NULL && canon == NULL)				      \
+	{								      \
+	  canonbuf = __strdup (localcanon);				      \
+	  if (canonbuf == NULL)						      \
+	    {								      \
+	      result = -EAI_SYSTEM;					      \
+	      goto free_and_return;					      \
+	    }								      \
+	  canon = canonbuf;						      \
+	}								      \
       if (_family == AF_INET6 && *pat != NULL)				      \
 	got_ipv6 = true;						      \
     }									      \
@@ -330,7 +337,7 @@ getcanonname (service_user *nip, struct gaih_addrtuple *at, const char *name)
 	   string.  */
 	s = (char *) name;
     }
-  return strdup (name);
+  return __strdup (name);
 }
 
 static int