From: Adhemerval Zanella Date: Wed, 10 Nov 2021 18:26:52 +0000 (-0300) Subject: inet: Remove strdupa from nrl_domainname() X-Git-Tag: glibc-2.36~507 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b3c68b10afddf160c09c6862341b7fcfcaac901c;p=thirdparty%2Fglibc.git 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 --- diff --git a/inet/getnameinfo.c b/inet/getnameinfo.c index 5965912c9e7..d3387dd16a1 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