mirror of
git://sourceware.org/git/glibc.git
synced 2025-02-17 13:00:43 +08:00
Linux gethostid: Check for NULL value from gethostbyname_r [BZ #23679]
A NULL value can happen with certain gethostbyname_r failures.
This commit is contained in:
parent
791b350dc7
commit
1214ba06e6
@ -1,3 +1,8 @@
|
||||
2018-09-20 Mingli Yu <Mingli.Yu@windriver.com>
|
||||
|
||||
* sysdeps/unix/sysv/linux/gethostid.c (gethostid): Check for NULL
|
||||
value from gethostbyname_r.
|
||||
|
||||
2018-09-19 Carlos O'Donell <carlos@redhat.com>
|
||||
|
||||
* stdlib/tst-setcontext9.c (f1): Rename to...
|
||||
|
@ -102,12 +102,12 @@ gethostid (void)
|
||||
{
|
||||
int ret = __gethostbyname_r (hostname, &hostbuf,
|
||||
tmpbuf.data, tmpbuf.length, &hp, &herr);
|
||||
if (ret == 0)
|
||||
if (ret == 0 && hp != NULL)
|
||||
break;
|
||||
else
|
||||
{
|
||||
/* Enlarge the buffer on ERANGE. */
|
||||
if (herr == NETDB_INTERNAL && errno == ERANGE)
|
||||
if (ret != 0 && herr == NETDB_INTERNAL && errno == ERANGE)
|
||||
{
|
||||
if (!scratch_buffer_grow (&tmpbuf))
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user