summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/getnetnamadr.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/getnetnamadr.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/getnetnamadr.c')
-rw-r--r--lib/libc/net/getnetnamadr.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/libc/net/getnetnamadr.c b/lib/libc/net/getnetnamadr.c
index ec7e94b..9aa4d51 100644
--- a/lib/libc/net/getnetnamadr.c
+++ b/lib/libc/net/getnetnamadr.c
@@ -360,13 +360,17 @@ getnetbyname_r(const char *name, struct netent *ne, char *buffer,
#endif
{ 0 }
};
- int rval, ret_errno;
+ int rval, ret_errno = 0;
rval = _nsdispatch((void *)result, dtab, NSDB_NETWORKS,
"getnetbyname_r", default_src, name, ne, buffer, buflen,
&ret_errno, h_errorp);
- return ((rval == NS_SUCCESS) ? 0 : -1);
+ if (rval != NS_SUCCESS) {
+ errno = ret_errno;
+ return ((ret_errno != 0) ? ret_errno : -1);
+ }
+ return (0);
}
int
@@ -388,13 +392,17 @@ getnetbyaddr_r(uint32_t addr, int af, struct netent *ne, char *buffer,
#endif
{ 0 }
};
- int rval, ret_errno;
+ int rval, ret_errno = 0;
rval = _nsdispatch((void *)result, dtab, NSDB_NETWORKS,
"getnetbyaddr_r", default_src, addr, af, ne, buffer, buflen,
&ret_errno, h_errorp);
- return ((rval == NS_SUCCESS) ? 0 : -1);
+ if (rval != NS_SUCCESS) {
+ errno = ret_errno;
+ return ((ret_errno != 0) ? ret_errno : -1);
+ }
+ return (0);
}
struct netent *
OpenPOWER on IntegriCloud