public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc] inet: Remove strdupa from nrl_domainname() Date: Tue, 8 Mar 2022 15:54:09 +0000 (GMT) [thread overview] Message-ID: <20220308155409.1AD9A385C418@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b3c68b10afddf160c09c6862341b7fcfcaac901c commit b3c68b10afddf160c09c6862341b7fcfcaac901c Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> 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 <dj@redhat.com> 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
reply other threads:[~2022-03-08 15:54 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220308155409.1AD9A385C418@sourceware.org \ --to=azanella@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).