summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/getnetbyht.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/getnetbyht.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/getnetbyht.c')
-rw-r--r--lib/libc/net/getnetbyht.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/libc/net/getnetbyht.c b/lib/libc/net/getnetbyht.c
index 2bbba06..d2df570 100644
--- a/lib/libc/net/getnetbyht.c
+++ b/lib/libc/net/getnetbyht.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
+#include <errno.h>
#include <netdb.h>
#include <resolv.h>
#include <stdio.h>
@@ -162,8 +163,11 @@ getnetent_r(struct netent *nptr, char *buffer, size_t buflen,
}
if (getnetent_p(&ne, ned) != 0)
return (-1);
- if (__copy_netent(&ne, nptr, buffer, buflen) != 0)
- return (-1);
+ if (__copy_netent(&ne, nptr, buffer, buflen) != 0) {
+ RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
+ *h_errnop = statp->res_h_errno;
+ return ((errno != 0) ? errno : -1);
+ }
*result = nptr;
return (0);
}
@@ -226,8 +230,10 @@ found:
return (NS_NOTFOUND);
}
if (__copy_netent(&ne, nptr, 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 netent **)rval) = nptr;
return (NS_SUCCESS);
@@ -272,8 +278,10 @@ _ht_getnetbyaddr(void *rval, void *cb_data, va_list ap)
return (NS_NOTFOUND);
}
if (__copy_netent(&ne, nptr, 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 netent **)rval) = nptr;
return (NS_SUCCESS);
OpenPOWER on IntegriCloud