diff options
author | Mingli Yu <Mingli.Yu@windriver.com> | 2018-09-20 12:02:48 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2018-09-20 12:02:48 +0200 |
commit | 1214ba06e6771acb953a190091b0f6055c64fd25 (patch) | |
tree | 2d153421a34ad65f7729db9042595e877d18df94 | |
parent | 791b350dc725545e3f9b5db0f97ebdbc60c9735f (diff) | |
download | glibc-1214ba06e6771acb953a190091b0f6055c64fd25.tar.gz glibc-1214ba06e6771acb953a190091b0f6055c64fd25.tar.xz glibc-1214ba06e6771acb953a190091b0f6055c64fd25.zip |
Linux gethostid: Check for NULL value from gethostbyname_r [BZ #23679]
A NULL value can happen with certain gethostbyname_r failures.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/gethostid.c | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index d5becac41c..4a66ea4c2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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... 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; |