aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux
diff options
context:
space:
mode:
authorMingli Yu <Mingli.Yu@windriver.com>2018-09-20 12:41:13 +0200
committerFlorian Weimer <fweimer@redhat.com>2018-09-20 12:41:13 +0200
commite7d22db29cfdd2f1fb97a70a76fa53d151569945 (patch)
treebb34d1cfbe6efbc93bdb6b1b8098e22955539f68 /sysdeps/unix/sysv/linux
parent1fe2b9ca8a50aaa789d72944b5a91f1d35337adc (diff)
downloadglibc-e7d22db29cfdd2f1fb97a70a76fa53d151569945.tar
glibc-e7d22db29cfdd2f1fb97a70a76fa53d151569945.tar.gz
glibc-e7d22db29cfdd2f1fb97a70a76fa53d151569945.tar.bz2
glibc-e7d22db29cfdd2f1fb97a70a76fa53d151569945.zip
Linux gethostid: Check for NULL value from gethostbyname_r [BZ #23679]
A NULL value can happen with certain gethostbyname_r failures. (cherry picked from commit 1214ba06e6771acb953a190091b0f6055c64fd25)
Diffstat (limited to 'sysdeps/unix/sysv/linux')
-rw-r--r--sysdeps/unix/sysv/linux/gethostid.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c
index 2e20f034dc..ee0190e7f9 100644
--- a/sysdeps/unix/sysv/linux/gethostid.c
+++ b/sysdeps/unix/sysv/linux/gethostid.c
@@ -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;