diff options
author | peter <peter@FreeBSD.org> | 1999-08-04 14:41:39 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1999-08-04 14:41:39 +0000 |
commit | fce0d9b321de631d62c079179ff70ecfd90a2356 (patch) | |
tree | a05c00ed11f7e5c83798ea87bd9b085c1b931c78 /sys/nfs | |
parent | ed41b168e64b29b5eb0a5ed2fe46198ee565a6ed (diff) | |
download | FreeBSD-src-fce0d9b321de631d62c079179ff70ecfd90a2356.zip FreeBSD-src-fce0d9b321de631d62c079179ff70ecfd90a2356.tar.gz |
Don't over-allocate and over-copy shorter NFSv2 filehandles and then
correct the pointers afterwards.
It's kinda bogus that we generate a 24 (?) byte filehandle (2 x int32
fsid and 16 byte VFS fhandle) and pad it out to 64 bytes for NFSv3 with
garbage. The whole point of NFSv3's variable filehandle length was
to allow for shorter handles, both in memory and over the wire. I plan
on taking a shot at fixing this shortly.
Diffstat (limited to 'sys/nfs')
-rw-r--r-- | sys/nfs/nfs_common.h | 21 | ||||
-rw-r--r-- | sys/nfs/nfsm_subs.h | 21 |
2 files changed, 22 insertions, 20 deletions
diff --git a/sys/nfs/nfs_common.h b/sys/nfs/nfs_common.h index 5efe149..f70645f 100644 --- a/sys/nfs/nfs_common.h +++ b/sys/nfs/nfs_common.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95 - * $Id: nfsm_subs.h,v 1.23 1999/06/05 05:35:03 peter Exp $ + * $Id: nfsm_subs.h,v 1.24 1999/06/23 04:44:14 julian Exp $ */ @@ -419,24 +419,25 @@ struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid, } } #define nfsm_srvmtofh(f) \ - { int fhlen = NFSX_V3FH; \ + do { \ + int fhlen; \ if (nfsd->nd_flag & ND_NFSV3) { \ nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ fhlen = fxdr_unsigned(int, *tl); \ - if (fhlen == 0) { \ - bzero((caddr_t)(f), NFSX_V3FH); \ - } else if (fhlen != NFSX_V3FH) { \ + if (fhlen != 0 && fhlen != NFSX_V3FH) { \ error = EBADRPC; \ nfsm_reply(0); \ } \ + } else { \ + fhlen = NFSX_V2FH; \ } \ if (fhlen != 0) { \ - nfsm_dissect(tl, u_int32_t *, NFSX_V3FH); \ - bcopy((caddr_t)tl, (caddr_t)(f), NFSX_V3FH); \ - if ((nfsd->nd_flag & ND_NFSV3) == 0) \ - nfsm_adv(NFSX_V2FH - NFSX_V3FH); \ + nfsm_dissect(tl, u_int32_t *, fhlen); \ + bcopy((caddr_t)tl, (caddr_t)(f), fhlen); \ + } else {\ + bzero((caddr_t)(f), NFSX_V3FH); \ } \ - } + } while (0) #define nfsm_clget \ if (bp >= be) { \ diff --git a/sys/nfs/nfsm_subs.h b/sys/nfs/nfsm_subs.h index 5efe149..f70645f 100644 --- a/sys/nfs/nfsm_subs.h +++ b/sys/nfs/nfsm_subs.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95 - * $Id: nfsm_subs.h,v 1.23 1999/06/05 05:35:03 peter Exp $ + * $Id: nfsm_subs.h,v 1.24 1999/06/23 04:44:14 julian Exp $ */ @@ -419,24 +419,25 @@ struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid, } } #define nfsm_srvmtofh(f) \ - { int fhlen = NFSX_V3FH; \ + do { \ + int fhlen; \ if (nfsd->nd_flag & ND_NFSV3) { \ nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ fhlen = fxdr_unsigned(int, *tl); \ - if (fhlen == 0) { \ - bzero((caddr_t)(f), NFSX_V3FH); \ - } else if (fhlen != NFSX_V3FH) { \ + if (fhlen != 0 && fhlen != NFSX_V3FH) { \ error = EBADRPC; \ nfsm_reply(0); \ } \ + } else { \ + fhlen = NFSX_V2FH; \ } \ if (fhlen != 0) { \ - nfsm_dissect(tl, u_int32_t *, NFSX_V3FH); \ - bcopy((caddr_t)tl, (caddr_t)(f), NFSX_V3FH); \ - if ((nfsd->nd_flag & ND_NFSV3) == 0) \ - nfsm_adv(NFSX_V2FH - NFSX_V3FH); \ + nfsm_dissect(tl, u_int32_t *, fhlen); \ + bcopy((caddr_t)tl, (caddr_t)(f), fhlen); \ + } else {\ + bzero((caddr_t)(f), NFSX_V3FH); \ } \ - } + } while (0) #define nfsm_clget \ if (bp >= be) { \ |