[uClibc]gethostbyname_r fails when there's no /etc/hosts
Mike McDonald
mikemac at mikemac.com
Fri Apr 12 21:22:48 UTC 2002
If both the /etc/hosts and /etc/config/hosts files do not exist,
get_hosts_byname_r() will set errno to ENOENT and return -1.
gethostbyname_r() then completely punts and returns -1. This even
happens if the call was gethostbyname("192.168.0.1") which it should
handle. The point of the error is line 1581 in libc/inet/resolv.c:
switch (*h_errnop) {
case HOST_NOT_FOUND:
case NO_ADDRESS:
break;
default:
return i;
}
should be something like:
switch (*h_errnop) {
case HOST_NOT_FOUND:
case NO_ADDRESS:
break;
case NETDB_INTERNAL:
if (errno == ENOENT)
break;
return i;
default:
return i;
}
Another approach to fixing this would be to move the inet_aton()
code ahead of the host table code.
Oh, this is in version 0.9.11.
Mike McDonald
mikemac at mikemac.com
More information about the uClibc
mailing list