nscd and getxxxxx_r () are all screwed up.

H.J. Lu hjl@varesearch.com
Mon Aug 9 18:48:00 GMT 1999


nscd and getxxxxx_r () in glibc 2.1.2 are all screwed up. hstcache.c
in nscd has:

  while (__gethostbyname2_r (key, AF_INET, &resultbuf, buffer, buflen, 
                             &hst, &h_errno) != 0
         && h_errno == NETDB_INTERNAL
         && errno == ERANGE) 
    {
      errno = 0;
      buflen += 256; 
      buffer = alloca (buflen);
    }

However, when getanswer_r in resolve/nss_dns/dns-host.c runs out of
buffer around line 619, it never bothers to set errno nor h_errno. It
does that with


	if (result->h_name == NULL)
	  {
	    ....
	  }


It is incorrect since getanswer_r can run out of memory after 
result->h_name is set. It looks like a mess to me. I hope someone
will fix it soon.


-- 
H.J. Lu (hjl@gnu.org)


More information about the Libc-hacker mailing list