Message ID | 87zhwdjjmd.fsf@oldenburg.str.redhat.com |
---|---|
State | New |
Headers | show |
Series | Linux gethostid: Check for NULL value from gethostbyname_r [BZ #23679] | expand |
On 2018年09月20日 04:51, Florian Weimer wrote: > Compared to the version posted on Bugzilla, I added a check on ret. If > ret == 0 and hp == NULL, herr and errno are not necessarily valid. > > Okay for master? Thanks Florian for your respond! I'm fine with your update for the patch. Thanks, Mingli > > Thanks, > Florian > > Commit message: > > Linux gethostid: Check for NULL value from gethostbyname_r [BZ #23679] > > A NULL value can happen with certain gethostbyname_r failures. > > ChangeLog entry: > > 2018-09-19 Mingli Yu <Mingli.Yu@windriver.com> > > * sysdeps/unix/sysv/linux/gethostid.c (gethostid): Check for NULL > value from gethostbyname_r. > > 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; >
* Mingli Yu: > On 2018年09月20日 04:51, Florian Weimer wrote: >> Compared to the version posted on Bugzilla, I added a check on ret. If >> ret == 0 and hp == NULL, herr and errno are not necessarily valid. >> >> Okay for master? > > Thanks Florian for your respond! I'm fine with your update for the > patch. Thanks, I will check it in. Florian
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;