summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/gethostbydns.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/net/gethostbydns.c')
-rw-r--r--lib/libc/net/gethostbydns.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c
index ff93972..f301c88 100644
--- a/lib/libc/net/gethostbydns.c
+++ b/lib/libc/net/gethostbydns.c
@@ -522,23 +522,34 @@ _dns_gethostbyname(void *rval, void *cb_data, va_list ap)
free(buf);
dprintf("res_nsearch failed (%d)\n", n, statp);
*h_errnop = statp->res_h_errno;
- return (0);
+ return (NS_NOTFOUND);
} else if (n > sizeof(buf->buf)) {
free(buf);
dprintf("static buffer is too small (%d)\n", n, statp);
*h_errnop = statp->res_h_errno;
- return (0);
+ return (NS_UNAVAIL);
}
error = gethostanswer(buf, n, name, type, &he, hed, statp);
free(buf);
if (error != 0) {
*h_errnop = statp->res_h_errno;
- return (NS_NOTFOUND);
+ switch (statp->res_h_errno) {
+ case HOST_NOT_FOUND:
+ return (NS_NOTFOUND);
+ case TRY_AGAIN:
+ return (NS_TRYAGAIN);
+ default:
+ return (NS_UNAVAIL);
+ }
+ /*NOTREACHED*/
}
if (__copy_hostent(&he, hptr, buffer, buflen) != 0) {
+ *errnop = errno;
+ RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
*h_errnop = statp->res_h_errno;
- return (NS_NOTFOUND);
+ return (NS_RETURN);
}
+ RES_SET_H_ERRNO(statp, NETDB_SUCCESS);
*((struct hostent **)rval) = hptr;
return (NS_SUCCESS);
}
@@ -629,7 +640,15 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap)
if (gethostanswer(buf, n, qbuf, T_PTR, &he, hed, statp) != 0) {
free(buf);
*h_errnop = statp->res_h_errno;
- return (NS_NOTFOUND); /* h_errno was set by gethostanswer() */
+ switch (statp->res_h_errno) {
+ case HOST_NOT_FOUND:
+ return (NS_NOTFOUND);
+ case TRY_AGAIN:
+ return (NS_TRYAGAIN);
+ default:
+ return (NS_UNAVAIL);
+ }
+ /*NOTREACHED*/
}
free(buf);
#ifdef SUNSECURITY
@@ -683,11 +702,13 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap)
he.h_addrtype = AF_INET6;
he.h_length = NS_IN6ADDRSZ;
}
- RES_SET_H_ERRNO(statp, NETDB_SUCCESS);
if (__copy_hostent(&he, hptr, buffer, buflen) != 0) {
+ *errnop = errno;
+ RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
*h_errnop = statp->res_h_errno;
- return (NS_NOTFOUND);
+ return (NS_RETURN);
}
+ RES_SET_H_ERRNO(statp, NETDB_SUCCESS);
*((struct hostent **)rval) = hptr;
return (NS_SUCCESS);
}
OpenPOWER on IntegriCloud