diff options
author | vangyzen <vangyzen@FreeBSD.org> | 2017-03-17 14:54:10 +0000 |
---|---|---|
committer | vangyzen <vangyzen@FreeBSD.org> | 2017-03-17 14:54:10 +0000 |
commit | 5ebfb876ead3dd5491730d0a543aba065d39d55d (patch) | |
tree | 60e75e61e458ac8a4a1f540317c9b35ba1b0c445 /sys/fs/nfsserver | |
parent | d4eaf4dc21922349befba86e51d55edae9355763 (diff) | |
download | FreeBSD-src-5ebfb876ead3dd5491730d0a543aba065d39d55d.zip FreeBSD-src-5ebfb876ead3dd5491730d0a543aba065d39d55d.tar.gz |
MFC r313821 r315277 r315286
Use inet_ntoa_r() instead of inet_ntoa() throughout the kernel.
inet_ntoa() cannot be used safely in a multithreaded environment
because it uses a static local buffer. Instead, use inet_ntoa_r()
with a buffer on the caller's stack, except for KTR messages.
KTR can correctly log the immediate integral values passed to it,
as well as constant strings, but not non-constant strings,
since they might change by the time ktrdump retrieves them.
Therefore, use hex notation in KTR messages.
Sponsored by: Dell EMC
Diffstat (limited to 'sys/fs/nfsserver')
-rw-r--r-- | sys/fs/nfsserver/nfs_nfsdkrpc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/fs/nfsserver/nfs_nfsdkrpc.c b/sys/fs/nfsserver/nfs_nfsdkrpc.c index fb4c525..fc34969 100644 --- a/sys/fs/nfsserver/nfs_nfsdkrpc.c +++ b/sys/fs/nfsserver/nfs_nfsdkrpc.c @@ -174,7 +174,11 @@ nfssvc_program(struct svc_req *rqst, SVCXPRT *xprt) if (port >= IPPORT_RESERVED && nd.nd_procnum != NFSPROC_NULL) { #ifdef INET6 - char b6[INET6_ADDRSTRLEN]; + char buf[INET6_ADDRSTRLEN]; +#else + char buf[INET_ADDRSTRLEN]; +#endif +#ifdef INET6 #if defined(KLD_MODULE) /* Do not use ip6_sprintf: the nfs module should work without INET6. */ #define ip6_sprintf(buf, a) \ @@ -189,12 +193,12 @@ nfssvc_program(struct svc_req *rqst, SVCXPRT *xprt) printf("NFS request from unprivileged port (%s:%d)\n", #ifdef INET6 sin->sin_family == AF_INET6 ? - ip6_sprintf(b6, &satosin6(sin)->sin6_addr) : + ip6_sprintf(buf, &satosin6(sin)->sin6_addr) : #if defined(KLD_MODULE) #undef ip6_sprintf #endif #endif - inet_ntoa(sin->sin_addr), port); + inet_ntoa_r(sin->sin_addr, buf), port); svcerr_weakauth(rqst); svc_freereq(rqst); m_freem(nd.nd_mrep); |