summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/gethostbyht.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/net/gethostbyht.c')
-rw-r--r--lib/libc/net/gethostbyht.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/libc/net/gethostbyht.c b/lib/libc/net/gethostbyht.c
index 8c41d9a..4253d49 100644
--- a/lib/libc/net/gethostbyht.c
+++ b/lib/libc/net/gethostbyht.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include <netdb.h>
#include <stdio.h>
#include <ctype.h>
+#include <errno.h>
#include <string.h>
#include <stdarg.h>
#include <nsswitch.h>
@@ -192,8 +193,11 @@ gethostent_r(struct hostent *hptr, char *buffer, size_t buflen,
}
if (gethostent_p(&he, hed, statp->options & RES_USE_INET6, statp) != 0)
return (-1);
- if (__copy_hostent(&he, hptr, buffer, buflen) != 0)
- return (-1);
+ if (__copy_hostent(&he, hptr, buffer, buflen) != 0) {
+ RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
+ *h_errnop = statp->res_h_errno;
+ return ((errno != 0) ? errno : -1);
+ }
*result = hptr;
return (0);
}
@@ -268,8 +272,10 @@ found:
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);
}
*((struct hostent **)rval) = hptr;
return (NS_SUCCESS);
@@ -323,8 +329,10 @@ _ht_gethostbyaddr(void *rval, void *cb_data, va_list ap)
if (error != 0)
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);
}
*((struct hostent **)rval) = hptr;
return (NS_SUCCESS);
OpenPOWER on IntegriCloud