From: Florian Weimer <fw@deneb.enyo.de>
To: Andreas Schwab <schwab@suse.de>
Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
libc-alpha@sourceware.org
Subject: Re: [PATCH] gethostid (Linux variant): Switch to struct scratch_buffer [BZ #18023]
Date: Tue, 18 Sep 2018 10:59:00 -0000 [thread overview]
Message-ID: <87worjvzpc.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <mvm4lenxemo.fsf@suse.de> (Andreas Schwab's message of "Tue, 18 Sep 2018 12:51:27 +0200")
* Andreas Schwab:
> On Jun 26 2018, Florian Weimer <fweimer@redhat.com> wrote:
>
>> @@ -88,29 +88,43 @@ gethostid (void)
>> return id;
>> }
>>
>> - /* Getting from the file was not successful. An intelligent guess for
>> - a unique number of a host is its IP address. Return this. */
>> + /* Getting from the file was not successful. An intelligent guess
>> + for a unique number of a host is its IP address. To get the IP
>> + address we need to know the host name. */
>> if (__gethostname (hostname, MAXHOSTNAMELEN) < 0 || hostname[0] == '\0')
>> /* This also fails. Return and arbitrary value. */
>> return 0;
>>
>> - buflen = 1024;
>> - buffer = __alloca (buflen);
>> -
>> - /* To get the IP address we need to know the host name. */
>> - while (__gethostbyname_r (hostname, &hostbuf, buffer, buflen, &hp, &herr)
>> - != 0
>> - || hp == NULL)
>> - if (herr != NETDB_INTERNAL || errno != ERANGE)
>> - return 0;
>> - else
>> - /* Enlarge buffer. */
>> - buffer = extend_alloca (buffer, buflen, 2 * buflen);
>> + /* Determine the IP address of the host name. */
>> + struct scratch_buffer tmpbuf;
>> + scratch_buffer_init (&tmpbuf);
>> + while (true)
>> + {
>> + int ret = __gethostbyname_r (hostname, &hostbuf,
>> + tmpbuf.data, tmpbuf.length, &hp, &herr);
>> + if (ret == 0)
>> + break;
>
> That fails to handle hp == NULL any more, see bug 23679.
Oops. Do you want me to write a patch?
next prev parent reply other threads:[~2018-09-18 10:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-26 15:46 Florian Weimer
2018-06-26 16:58 ` Adhemerval Zanella
2018-06-26 17:33 ` Florian Weimer
2018-06-26 17:52 ` Adhemerval Zanella
2018-09-18 10:51 ` Andreas Schwab
2018-09-18 10:59 ` Florian Weimer [this message]
2018-09-18 12:09 ` Andreas Schwab
2018-09-18 12:32 ` Florian Weimer
2018-06-26 18:16 ` DJ Delorie
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=87worjvzpc.fsf@mid.deneb.enyo.de \
--to=fw@deneb.enyo.de \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
--cc=schwab@suse.de \
/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: link
Be 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).