about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-11-10 15:26:52 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-03-08 12:51:29 -0300
commitb3c68b10afddf160c09c6862341b7fcfcaac901c (patch)
tree2cb301b0ffc17507555ac7c2131569e82cfd5884
parentc54d689269c7f10e7f7d28b1cb5b3a6a0dd5a889 (diff)
downloadglibc-b3c68b10afddf160c09c6862341b7fcfcaac901c.tar.gz
glibc-b3c68b10afddf160c09c6862341b7fcfcaac901c.tar.xz
glibc-b3c68b10afddf160c09c6862341b7fcfcaac901c.zip
inet: Remove strdupa from nrl_domainname()
We can use the already in place scratch_buffer.

Checked on x86_64-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
-rw-r--r--inet/getnameinfo.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/inet/getnameinfo.c b/inet/getnameinfo.c
index 5965912c9e..d3387dd16a 100644
--- a/inet/getnameinfo.c
+++ b/inet/getnameinfo.c
@@ -118,15 +118,15 @@ nrl_domainname_core (struct scratch_buffer *tmpbuf)
       else
 	{
 	  /* We need to preserve the hostname.  */
-	  const char *hstname = strdupa (tmpbuf->data);
-	  while (__gethostbyname_r (hstname, &th,
-				    tmpbuf->data,
-				    tmpbuf->length,
+	  size_t hstnamelen = strlen (tmpbuf->data) + 1;
+	  while (__gethostbyname_r (tmpbuf->data, &th,
+				    tmpbuf->data + hstnamelen,
+				    tmpbuf->length - hstnamelen,
 				    &h, &herror))
 	    {
 	      if (herror == NETDB_INTERNAL && errno == ERANGE)
 		{
-		  if (!scratch_buffer_grow (tmpbuf))
+		  if (!scratch_buffer_grow_preserve (tmpbuf))
 		    return;
 		}
 	      else