From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 1AD9A385C418; Tue, 8 Mar 2022 15:54:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1AD9A385C418 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc] inet: Remove strdupa from nrl_domainname() X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/master X-Git-Oldrev: c54d689269c7f10e7f7d28b1cb5b3a6a0dd5a889 X-Git-Newrev: b3c68b10afddf160c09c6862341b7fcfcaac901c Message-Id: <20220308155409.1AD9A385C418@sourceware.org> Date: Tue, 8 Mar 2022 15:54:09 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Mar 2022 15:54:09 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b3c68b10afddf160c09c6862341b7fcfcaac901c commit b3c68b10afddf160c09c6862341b7fcfcaac901c Author: Adhemerval Zanella Date: Wed Nov 10 15:26:52 2021 -0300 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: --- inet/getnameinfo.c | 10 +++++----- 1 file 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