diff options
author | ume <ume@FreeBSD.org> | 2010-08-13 06:39:54 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2010-08-13 06:39:54 +0000 |
commit | 5fdaddea72f2485c5731c35f4288d3a1f38627d6 (patch) | |
tree | 7a80afb7fd5c19cd871455a023feca5a38817d97 /lib/libc/net/getproto.c | |
parent | 05bcb2e515902ec297be8c84a0742b1893d700ec (diff) | |
download | FreeBSD-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/getproto.c')
-rw-r--r-- | lib/libc/net/getproto.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/libc/net/getproto.c b/lib/libc/net/getproto.c index 85b40e1..cb3a3ed 100644 --- a/lib/libc/net/getproto.c +++ b/lib/libc/net/getproto.c @@ -33,6 +33,7 @@ static char sccsid[] = "@(#)getproto.c 8.1 (Berkeley) 6/4/93"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <errno.h> #include <netdb.h> #include <nsswitch.h> #include "netdb_private.h" @@ -72,7 +73,7 @@ files_getprotobynumber(void *retval, void *mdata, va_list ap) errnop = va_arg(ap, int *); if ((ped = __protoent_data_init()) == NULL) { - *errnop = -1; + *errnop = errno; return (NS_NOTFOUND); } @@ -83,12 +84,12 @@ files_getprotobynumber(void *retval, void *mdata, va_list ap) if (!ped->stayopen) __endprotoent_p(ped); if (error != 0) { - *errnop = -1; + *errnop = errno; return (NS_NOTFOUND); } if (__copy_protoent(&pe, pptr, buffer, buflen) != 0) { - *errnop = -1; - return (NS_NOTFOUND); + *errnop = errno; + return (NS_RETURN); } *((struct protoent **)retval) = pptr; @@ -120,10 +121,11 @@ getprotobynumber_r(int proto, struct protoent *pptr, char *buffer, rv = nsdispatch(result, dtab, NSDB_PROTOCOLS, "getprotobynumber_r", defaultsrc, proto, 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); } struct protoent * |