summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/gethostbydns.c
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2010-08-13 06:39:54 +0000
committerume <ume@FreeBSD.org>2010-08-13 06:39:54 +0000
commit5fdaddea72f2485c5731c35f4288d3a1f38627d6 (patch)
tree7a80afb7fd5c19cd871455a023feca5a38817d97 /lib/libc/net/gethostbydns.c
parent05bcb2e515902ec297be8c84a0742b1893d700ec (diff)
downloadFreeBSD-src-5fdaddea72f2485c5731c35f4288d3a1f38627d6.zip
FreeBSD-src-5fdaddea72f2485c5731c35f4288d3a1f38627d6.tar.gz
- When there is no room for returning the result, nss backend
have to return ERANGE and terminate with NS_RETURN. - When gethostbyname_r(3) and the friends end with an error, set errno to the value nss backend returns, and return errno value. PR: kern/131623 MFC after: 2 weeks
Diffstat (limited to 'lib/libc/net/gethostbydns.c')
-rw-r--r--lib/libc/net/gethostbydns.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c
index ff93972..dc10479 100644
--- a/lib/libc/net/gethostbydns.c
+++ b/lib/libc/net/gethostbydns.c
@@ -536,9 +536,12 @@ _dns_gethostbyname(void *rval, void *cb_data, va_list ap)
return (NS_NOTFOUND);
}
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);
}
@@ -683,11 +686,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