summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/getprotoent.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/getprotoent.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/getprotoent.c')
-rw-r--r--lib/libc/net/getprotoent.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/libc/net/getprotoent.c b/lib/libc/net/getprotoent.c
index dda5d18..ccd5e12 100644
--- a/lib/libc/net/getprotoent.c
+++ b/lib/libc/net/getprotoent.c
@@ -424,8 +424,10 @@ files_getprotoent_r(void *retval, void *mdata, va_list ap)
buflen = va_arg(ap, size_t);
errnop = va_arg(ap, int *);
- if ((ped = __protoent_data_init()) == NULL)
- return (-1);
+ if ((ped = __protoent_data_init()) == NULL) {
+ *errnop = errno;
+ return (NS_NOTFOUND);
+ }
if (__getprotoent_p(&pe, ped) != 0) {
*errnop = errno;
@@ -434,7 +436,7 @@ files_getprotoent_r(void *retval, void *mdata, va_list ap)
if (__copy_protoent(&pe, pptr, buffer, buflen) != 0) {
*errnop = errno;
- return (NS_NOTFOUND);
+ return (NS_RETURN);
}
*((struct protoent **)retval) = pptr;
@@ -490,10 +492,11 @@ getprotoent_r(struct protoent *pptr, char *buffer, size_t buflen,
rv = nsdispatch(result, dtab, NSDB_PROTOCOLS, "getprotoent_r",
defaultsrc, pptr, buffer, buflen, &ret_errno);
- if (rv == NS_SUCCESS)
- return (0);
- else
- return (ret_errno);
+ if (rv != NS_SUCCESS) {
+ errno = ret_errno;
+ return ((ret_errno != 0) ? ret_errno : -1);
+ }
+ return (0);
}
void
OpenPOWER on IntegriCloud