diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/nfs/nfs_common.c | 43 | ||||
-rw-r--r-- | sys/nfs/nfs_common.h | 22 | ||||
-rw-r--r-- | sys/nfsclient/nfs_socket.c | 8 | ||||
-rw-r--r-- | sys/nfsclient/nfs_subs.c | 54 | ||||
-rw-r--r-- | sys/nfsclient/nfs_vfsops.c | 4 | ||||
-rw-r--r-- | sys/nfsclient/nfs_vnops.c | 36 | ||||
-rw-r--r-- | sys/nfsserver/nfs_serv.c | 42 | ||||
-rw-r--r-- | sys/nfsserver/nfs_srvsock.c | 8 | ||||
-rw-r--r-- | sys/nfsserver/nfs_srvsubs.c | 106 |
9 files changed, 157 insertions, 166 deletions
diff --git a/sys/nfs/nfs_common.c b/sys/nfs/nfs_common.c index 5635945..b4123f9 100644 --- a/sys/nfs/nfs_common.c +++ b/sys/nfs/nfs_common.c @@ -164,29 +164,30 @@ nfsm_mbuftouio(struct mbuf **mrep, struct uio *uiop, int siz, caddr_t *dpos) /* * Help break down an mbuf chain by setting the first siz bytes contiguous * pointed to by returned val. - * This is used by the macros nfsm_dissect and nfsm_dissecton for tough + * This is used by the macros nfsm_dissect for tough * cases. (The macros use the vars. dpos and dpos2) */ -int -nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left, caddr_t *cp2) +void * +nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left) { struct mbuf *mp, *mp2; int siz2, xfer; caddr_t ptr; + void *ret; mp = *mdp; while (left == 0) { *mdp = mp = mp->m_next; if (mp == NULL) - return (EBADRPC); + return NULL; left = mp->m_len; *dposp = mtod(mp, caddr_t); } if (left >= siz) { - *cp2 = *dposp; + ret = *dposp; *dposp += siz; } else if (mp->m_next == NULL) { - return (EBADRPC); + return NULL; } else if (siz > MHLEN) { panic("nfs S too big"); } else { @@ -195,7 +196,8 @@ nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left, caddr_t *cp2) mp->m_next = mp2; mp->m_len -= left; mp = mp2; - *cp2 = ptr = mtod(mp, caddr_t); + ptr = mtod(mp, caddr_t); + ret = ptr; bcopy(*dposp, ptr, left); /* Copy what was left */ siz2 = siz-left; ptr += left; @@ -203,7 +205,7 @@ nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left, caddr_t *cp2) /* Loop around copying up the siz2 bytes */ while (siz2 > 0) { if (mp2 == NULL) - return (EBADRPC); + return NULL; xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2; if (xfer > 0) { bcopy(mtod(mp2, caddr_t), ptr, xfer); @@ -219,7 +221,7 @@ nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left, caddr_t *cp2) *mdp = mp2; *dposp = mtod(mp2, caddr_t); } - return (0); + return ret; } /* @@ -266,33 +268,30 @@ nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos) return ret; } -int -nfsm_dissect_xx(void **a, int s, struct mbuf **md, caddr_t *dpos) +void * +nfsm_dissect_xx(int s, struct mbuf **md, caddr_t *dpos) { int t1; char *cp2; + void *ret; t1 = mtod(*md, caddr_t) + (*md)->m_len - *dpos; if (t1 >= s) { - *a = *dpos; + ret = *dpos; *dpos += s; - return 0; + return ret; } - t1 = nfsm_disct(md, dpos, s, t1, &cp2); - if (t1 != 0) - return t1; - *a = cp2; - return 0; + cp2 = nfsm_disct(md, dpos, s, t1); + return cp2; } int nfsm_strsiz_xx(int *s, int m, u_int32_t **tl, struct mbuf **mb, caddr_t *bpos) { - int ret; - ret = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, mb, bpos); - if (ret) - return ret; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, mb, bpos); + if (*tl == NULL) + return EBADRPC; *s = fxdr_unsigned(int32_t, **tl); if (*s > m) return EBADRPC; diff --git a/sys/nfs/nfs_common.h b/sys/nfs/nfs_common.h index c43dd3e..a751a67 100644 --- a/sys/nfs/nfs_common.h +++ b/sys/nfs/nfs_common.h @@ -57,28 +57,28 @@ extern nfstype nfsv3_type[]; int nfs_adv(struct mbuf **, caddr_t *, int, int); void *nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos); -int nfsm_dissect_xx(void **a, int s, struct mbuf **md, caddr_t *dpos); +void *nfsm_dissect_xx(int s, struct mbuf **md, caddr_t *dpos); int nfsm_strsiz_xx(int *s, int m, u_int32_t **tl, struct mbuf **mb, caddr_t *bpos); int nfsm_adv_xx(int s, u_int32_t **tl, struct mbuf **md, caddr_t *dpos); u_quad_t nfs_curusec(void); -int nfsm_disct(struct mbuf **, caddr_t *, int, int, caddr_t *); +void *nfsm_disct(struct mbuf **, caddr_t *, int, int); #define nfsm_build(c, s) \ - (c)nfsm_build_xx((s), &mb, &bpos); \ + (c)nfsm_build_xx((s), &mb, &bpos) -/* XXX 'c' arg (type) is not used */ -#define nfsm_dissect(a, c, s) \ -do { \ - int t1; \ - t1 = nfsm_dissect_xx((void **)&(a), (s), &md, &dpos); \ - if (t1) { \ - error = t1; \ +#define nfsm_dissect(c, s) \ +({ \ + void *ret; \ + ret = nfsm_dissect_xx((s), &md, &dpos); \ + if (ret == NULL) { \ + error = EBADRPC; \ m_freem(mrep); \ mrep = NULL; \ goto nfsmout; \ } \ -} while (0) + (c)ret; \ +}) #define nfsm_strsiz(s,m) \ do { \ diff --git a/sys/nfsclient/nfs_socket.c b/sys/nfsclient/nfs_socket.c index 4bf50e4..38c7783 100644 --- a/sys/nfsclient/nfs_socket.c +++ b/sys/nfsclient/nfs_socket.c @@ -745,7 +745,7 @@ nfs_reply(struct nfsreq *myrep) */ md = mrep; dpos = mtod(md, caddr_t); - nfsm_dissect(tl, u_int32_t *, 2*NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 2 * NFSX_UNSIGNED); rxid = *tl++; if (*tl != rpc_reply) { nfsstats.rpcinvalid++; @@ -979,7 +979,7 @@ tryagain: /* * break down the rpc header and check if ok */ - nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 3 * NFSX_UNSIGNED); if (*tl++ == rpc_msgdenied) { if (*tl == rpc_mismatch) error = EOPNOTSUPP; @@ -998,10 +998,10 @@ tryagain: i = fxdr_unsigned(int32_t, *tl); /* len */ if (i > 0) nfsm_adv(nfsm_rndup(i)); - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); /* 0 == ok */ if (*tl == 0) { - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); if (*tl != 0) { error = fxdr_unsigned(int, *tl); if ((nmp->nm_flag & NFSMNT_NFSV3) && diff --git a/sys/nfsclient/nfs_subs.c b/sys/nfsclient/nfs_subs.c index 2536b17..4b427b5 100644 --- a/sys/nfsclient/nfs_subs.c +++ b/sys/nfsclient/nfs_subs.c @@ -461,7 +461,7 @@ nfs_loadattrcache(struct vnode **vpp, struct mbuf **mdp, caddr_t *dposp, struct nfsnode *np; int32_t t1; caddr_t cp2; - int error = 0, rdev; + int rdev; struct mbuf *md; enum vtype vtyp; u_short vmode; @@ -470,8 +470,9 @@ nfs_loadattrcache(struct vnode **vpp, struct mbuf **mdp, caddr_t *dposp, md = *mdp; t1 = (mtod(md, caddr_t) + md->m_len) - *dposp; - if ((error = nfsm_disct(mdp, dposp, NFSX_FATTR(v3), t1, &cp2)) != 0) - return (error); + cp2 = nfsm_disct(mdp, dposp, NFSX_FATTR(v3), t1); + if (cp2 == NULL) + return EBADRPC; fp = (struct nfs_fattr *)cp2; if (v3) { vtyp = nfsv3tov_type(fp->fa_type); @@ -819,9 +820,9 @@ nfsm_mtofh_xx(struct vnode *d, struct vnode **v, int v3, int *f, int t1; if (v3) { - t1 = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (t1) - return (t1); + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; *f = fxdr_unsigned(int, **tl); } else *f = 1; @@ -835,9 +836,9 @@ nfsm_mtofh_xx(struct vnode *d, struct vnode **v, int v3, int *f, *v = NFSTOV(ttnp); } if (v3) { - t1 = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (t1) - return t1; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; if (*f) *f = fxdr_unsigned(int, **tl); else if (fxdr_unsigned(int, **tl)) @@ -857,20 +858,21 @@ int nfsm_getfh_xx(nfsfh_t **f, int *s, int v3, u_int32_t **tl, struct mbuf **md, caddr_t *dpos) { - int t1; if (v3) { - t1 = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (t1) - return t1; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; *s = fxdr_unsigned(int, **tl); - if (*s <= 0 || *s > NFSX_V3FHMAX) { + if (*s <= 0 || *s > NFSX_V3FHMAX) return EBADRPC; - } } else *s = NFSX_V2FH; - t1 = nfsm_dissect_xx((void **)f, nfsm_rndup(*s), md, dpos); - return t1; + *f = nfsm_dissect_xx(nfsm_rndup(*s), md, dpos); + if (*f == NULL) + return EBADRPC; + else + return 0; } @@ -895,9 +897,9 @@ nfsm_postop_attr_xx(struct vnode **v, int *f, int t1; struct vnode *ttvp = *v; - t1 = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (t1 != 0) - return t1; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; *f = fxdr_unsigned(int, **tl); if (*f != 0) { t1 = nfs_loadattrcache(&ttvp, md, dpos, (struct vattr *)0, 1); @@ -917,13 +919,13 @@ nfsm_wcc_data_xx(struct vnode **v, int *f, int ttattrf, ttretf = 0; int t1; - t1 = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (t1 != 0) - return t1; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; if (**tl == nfs_true) { - t1 = nfsm_dissect_xx((void **)tl, 6 * NFSX_UNSIGNED, md, dpos); - if (t1 != 0) - return t1; + *tl = nfsm_dissect_xx(6 * NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; if (*f) ttretf = (VTONFS(*v)->n_mtime == fxdr_unsigned(u_int32_t, *((*tl) + 2))); diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index cbf03aa..670a5aa 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -267,7 +267,7 @@ nfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) m_freem(mrep); goto nfsmout; } - nfsm_dissect(sfp, struct nfs_statfs *, NFSX_STATFS(v3)); + sfp = nfsm_dissect(struct nfs_statfs *, NFSX_STATFS(v3)); sbp->f_flags = nmp->nm_flag; sbp->f_iosize = nfs_iosize(nmp); if (v3) { @@ -323,7 +323,7 @@ nfs_fsinfo(struct nfsmount *nmp, struct vnode *vp, struct ucred *cred, nfsm_request(vp, NFSPROC_FSINFO, td, cred); nfsm_postop_attr(vp, retattr); if (!error) { - nfsm_dissect(fsp, struct nfsv3_fsinfo *, NFSX_V3FSINFO); + fsp = nfsm_dissect(struct nfsv3_fsinfo *, NFSX_V3FSINFO); pref = fxdr_unsigned(u_int32_t, fsp->fs_wtpref); if (pref < nmp->nm_wsize && pref >= NFS_FABLKSIZE) nmp->nm_wsize = (pref + NFS_FABLKSIZE - 1) & diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index 2473f3d..60a1cc9 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -283,7 +283,7 @@ nfs3_access_otw(struct vnode *vp, int wmode, struct thread *td, nfsm_request(vp, NFSPROC_ACCESS, td, cred); nfsm_postop_attr(vp, attrflag); if (!error) { - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); rmode = fxdr_unsigned(u_int32_t, *tl); np->n_mode = rmode; np->n_modeuid = cred->cr_uid; @@ -1040,7 +1040,7 @@ nfs_readrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) m_freem(mrep); goto nfsmout; } - nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 2 * NFSX_UNSIGNED); eof = fxdr_unsigned(int, *(tl + 1)); } else nfsm_loadattr(vp, (struct vattr *)0); @@ -1114,7 +1114,7 @@ nfs_writerpc(struct vnode *vp, struct uio *uiop, struct ucred *cred, wccflag = NFSV3_WCCCHK; nfsm_wcc_data(vp, wccflag); if (!error) { - nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED + tl = nfsm_dissect(u_int32_t *, 2 * NFSX_UNSIGNED + NFSX_V3WRITEVERF); rlen = fxdr_unsigned(int, *tl++); if (rlen == 0) { @@ -1985,7 +1985,7 @@ nfs_readdirrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) if (v3) { nfsm_postop_attr(vp, attrflag); if (!error) { - nfsm_dissect(tl, u_int32_t *, + tl = nfsm_dissect(u_int32_t *, 2 * NFSX_UNSIGNED); dnp->n_cookieverf.nfsuquad[0] = *tl++; dnp->n_cookieverf.nfsuquad[1] = *tl; @@ -1994,18 +1994,18 @@ nfs_readdirrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) goto nfsmout; } } - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); more_dirs = fxdr_unsigned(int, *tl); /* loop thru the dir entries, doctoring them to 4bsd form */ while (more_dirs && bigenough) { if (v3) { - nfsm_dissect(tl, u_int32_t *, + tl = nfsm_dissect(u_int32_t *, 3 * NFSX_UNSIGNED); fileno = fxdr_hyper(tl); len = fxdr_unsigned(int, *(tl + 2)); } else { - nfsm_dissect(tl, u_int32_t *, + tl = nfsm_dissect(u_int32_t *, 2 * NFSX_UNSIGNED); fileno = fxdr_unsigned(u_quad_t, *tl++); len = fxdr_unsigned(int, *tl); @@ -2053,10 +2053,10 @@ nfs_readdirrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) } else nfsm_adv(nfsm_rndup(len)); if (v3) { - nfsm_dissect(tl, u_int32_t *, + tl = nfsm_dissect(u_int32_t *, 3 * NFSX_UNSIGNED); } else { - nfsm_dissect(tl, u_int32_t *, + tl = nfsm_dissect(u_int32_t *, 2 * NFSX_UNSIGNED); } if (bigenough) { @@ -2073,7 +2073,7 @@ nfs_readdirrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) * If at end of rpc data, get the eof boolean */ if (!more_dirs) { - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); more_dirs = (fxdr_unsigned(int, *tl) == 0); } m_freem(mrep); @@ -2175,14 +2175,14 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) m_freem(mrep); goto nfsmout; } - nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 3 * NFSX_UNSIGNED); dnp->n_cookieverf.nfsuquad[0] = *tl++; dnp->n_cookieverf.nfsuquad[1] = *tl++; more_dirs = fxdr_unsigned(int, *tl); /* loop thru the dir entries, doctoring them to 4bsd form */ while (more_dirs && bigenough) { - nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 3 * NFSX_UNSIGNED); fileno = fxdr_hyper(tl); len = fxdr_unsigned(int, *(tl + 2)); if (len <= 0 || len > NFS_MAXNAMLEN) { @@ -2229,7 +2229,7 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) uiop->uio_resid -= tlen; } else nfsm_adv(nfsm_rndup(len)); - nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 3 * NFSX_UNSIGNED); if (bigenough) { cookie.nfsuquad[0] = *tl++; cookie.nfsuquad[1] = *tl++; @@ -2246,7 +2246,7 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) dpossav1 = dpos; mdsav1 = md; nfsm_adv(NFSX_V3FATTR); - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); doit = fxdr_unsigned(int, *tl); if (doit) { nfsm_getfh(fhp, fhsize, 1); @@ -2278,7 +2278,7 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) } } else { /* Just skip over the file handle */ - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); i = fxdr_unsigned(int, *tl); nfsm_adv(nfsm_rndup(i)); } @@ -2289,14 +2289,14 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) vput(newvp); newvp = NULLVP; } - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); more_dirs = fxdr_unsigned(int, *tl); } /* * If at end of rpc data, get the eof boolean */ if (!more_dirs) { - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); more_dirs = (fxdr_unsigned(int, *tl) == 0); } m_freem(mrep); @@ -2500,7 +2500,7 @@ nfs_commit(struct vnode *vp, u_quad_t offset, int cnt, struct ucred *cred, nfsm_request(vp, NFSPROC_COMMIT, td, cred); nfsm_wcc_data(vp, wccflag); if (!error) { - nfsm_dissect(tl, u_int32_t *, NFSX_V3WRITEVERF); + tl = nfsm_dissect(u_int32_t *, NFSX_V3WRITEVERF); if (bcmp((caddr_t)nmp->nm_verf, (caddr_t)tl, NFSX_V3WRITEVERF)) { bcopy((caddr_t)tl, (caddr_t)nmp->nm_verf, diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index 9e6a445..f28d638 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -187,7 +187,7 @@ nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, panic("nfsrv3_access: v3 proc called on a v2 connection"); fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, TRUE); if (error) { nfsm_reply(NFSX_UNSIGNED); @@ -320,14 +320,14 @@ nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, VATTR_NULL(vap); if (v3) { nfsm_srvsattr(vap); - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); gcheck = fxdr_unsigned(int, *tl); if (gcheck) { - nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 2 * NFSX_UNSIGNED); fxdr_nfsv3time(tl, &guard); } } else { - nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); + sp = nfsm_dissect(struct nfsv2_sattr *, NFSX_V2SATTR); /* * Nah nah nah nah na nah * There is a bug in the Sun client that puts 0xffff in the mode @@ -764,10 +764,10 @@ nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); if (v3) { - nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 2 * NFSX_UNSIGNED); off = fxdr_hyper(tl); } else { - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); off = (off_t)fxdr_unsigned(u_int32_t, *tl); } nfsm_srvstrsiz(reqlen, NFS_SRVMAXDATA(nfsd)); @@ -1027,12 +1027,12 @@ nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, vput(vp); vp = NULL; if (v3) { - nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 5 * NFSX_UNSIGNED); off = fxdr_hyper(tl); tl += 3; stable = fxdr_unsigned(int, *tl++); } else { - nfsm_dissect(tl, u_int32_t *, 4 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 4 * NFSX_UNSIGNED); off = (off_t)fxdr_unsigned(u_int32_t, *++tl); tl += 2; if (nfs_async) @@ -1245,12 +1245,12 @@ nfsrv_writegather(struct nfsrv_descript **ndp, struct nfssvc_sock *slp, */ nfsm_srvmtofh(&nfsd->nd_fh); if (v3) { - nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 5 * NFSX_UNSIGNED); nfsd->nd_off = fxdr_hyper(tl); tl += 3; nfsd->nd_stable = fxdr_unsigned(int, *tl++); } else { - nfsm_dissect(tl, u_int32_t *, 4 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 4 * NFSX_UNSIGNED); nfsd->nd_off = (off_t)fxdr_unsigned(u_int32_t, *++tl); tl += 2; if (nfs_async) @@ -1665,7 +1665,7 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, VATTR_NULL(vap); if (v3) { - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); how = fxdr_unsigned(int, *tl); switch (how) { case NFSV3CREATE_GUARDED: @@ -1678,7 +1678,7 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsm_srvsattr(vap); break; case NFSV3CREATE_EXCLUSIVE: - nfsm_dissect(cp, caddr_t, NFSX_V3CREATEVERF); + cp = nfsm_dissect(caddr_t, NFSX_V3CREATEVERF); bcopy(cp, cverf, NFSX_V3CREATEVERF); exclusive_flag = 1; if (nd.ni_vp == NULL) @@ -1687,7 +1687,7 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, }; vap->va_type = VREG; } else { - nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); + sp = nfsm_dissect(struct nfsv2_sattr *, NFSX_V2SATTR); vap->va_type = IFTOVT(fxdr_unsigned(u_int32_t, sp->sa_mode)); if (vap->va_type == VNON) vap->va_type = VREG; @@ -1922,7 +1922,7 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, error = 0; goto nfsmout; } - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); vtyp = nfsv3tov_type(*tl); if (vtyp != VCHR && vtyp != VBLK && vtyp != VSOCK && vtyp != VFIFO) { error = NFSERR_BADTYPE; @@ -1931,7 +1931,7 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, VATTR_NULL(vap); nfsm_srvsattr(vap); if (vtyp == VCHR || vtyp == VBLK) { - nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 2 * NFSX_UNSIGNED); major = fxdr_unsigned(u_int32_t, *tl++); minor = fxdr_unsigned(u_int32_t, *tl); vap->va_rdev = makeudev(major, minor); @@ -2570,7 +2570,7 @@ nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, io.uio_td = (struct thread *)0; nfsm_mtouio(&io, len2); if (!v3) { - nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); + sp = nfsm_dissect(struct nfsv2_sattr *, NFSX_V2SATTR); vap->va_mode = fxdr_unsigned(u_int16_t, sp->sa_mode); } *(pathcp + len2) = '\0'; @@ -2746,7 +2746,7 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, if (v3) { nfsm_srvsattr(vap); } else { - nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED); vap->va_mode = nfstov_mode(*tl++); } @@ -3003,13 +3003,13 @@ nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); if (v3) { - nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 5 * NFSX_UNSIGNED); toff = fxdr_hyper(tl); tl += 2; verf = fxdr_hyper(tl); tl += 2; } else { - nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 2 * NFSX_UNSIGNED); toff = fxdr_unsigned(u_quad_t, *tl++); verf = 0; /* shut up gcc */ } @@ -3295,7 +3295,7 @@ nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, panic("nfsrv_readdirplus: v3 proc called on a v2 connection"); fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); - nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 6 * NFSX_UNSIGNED); toff = fxdr_hyper(tl); tl += 2; verf = fxdr_hyper(tl); @@ -3630,7 +3630,7 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, (void) vn_start_write(vp, &mp, V_WAIT); vput(vp); vp = NULL; - nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 3 * NFSX_UNSIGNED); /* * XXX At this time VOP_FSYNC() does not accept offset and byte diff --git a/sys/nfsserver/nfs_srvsock.c b/sys/nfsserver/nfs_srvsock.c index c93d431..cb2276d 100644 --- a/sys/nfsserver/nfs_srvsock.c +++ b/sys/nfsserver/nfs_srvsock.c @@ -294,14 +294,14 @@ nfs_getreq(struct nfsrv_descript *nd, struct nfsd *nfsd, int has_header) md = nd->nd_md; dpos = nd->nd_dpos; if (has_header) { - nfsm_dissect(tl, u_int32_t *, 10 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 10 * NFSX_UNSIGNED); nd->nd_retxid = fxdr_unsigned(u_int32_t, *tl++); if (*tl++ != rpc_call) { m_freem(mrep); return (EBADRPC); } } else - nfsm_dissect(tl, u_int32_t *, 8 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 8 * NFSX_UNSIGNED); nd->nd_repstat = 0; nd->nd_flag = 0; if (*tl++ != rpc_vers) { @@ -357,7 +357,7 @@ nfs_getreq(struct nfsrv_descript *nd, struct nfsd *nfsd, int has_header) return (EBADRPC); } nfsm_adv(nfsm_rndup(len)); - nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, 3 * NFSX_UNSIGNED); bzero((caddr_t)&nd->nd_cr, sizeof (struct ucred)); nd->nd_cr.cr_ref = 1; nd->nd_cr.cr_uid = fxdr_unsigned(uid_t, *tl++); @@ -367,7 +367,7 @@ nfs_getreq(struct nfsrv_descript *nd, struct nfsd *nfsd, int has_header) m_freem(mrep); return (EBADRPC); } - nfsm_dissect(tl, u_int32_t *, (len + 2) * NFSX_UNSIGNED); + tl = nfsm_dissect(u_int32_t *, (len + 2) * NFSX_UNSIGNED); for (i = 1; i <= len; i++) if (i < NGROUPS) nd->nd_cr.cr_groups[i] = fxdr_unsigned(gid_t, *tl++); diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c index 672ec12..c47de7d 100644 --- a/sys/nfsserver/nfs_srvsubs.c +++ b/sys/nfsserver/nfs_srvsubs.c @@ -1232,11 +1232,10 @@ int nfsm_srvstrsiz_xx(int *s, int m, u_int32_t **tl, struct mbuf **md, caddr_t *dpos) { - int ret; - ret = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (ret) - return ret; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; *s = fxdr_unsigned(int32_t, **tl); if (*s > m || *s <= 0) return EBADRPC; @@ -1247,11 +1246,10 @@ int nfsm_srvnamesiz_xx(int *s, u_int32_t **tl, struct mbuf **md, caddr_t *dpos) { - int ret; - ret = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (ret) - return ret; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; *s = fxdr_unsigned(int32_t, **tl); if (*s > NFS_MAXNAMLEN) return NFSERR_NAMETOL; @@ -1284,13 +1282,12 @@ int nfsm_srvmtofh_xx(fhandle_t *f, struct nfsrv_descript *nfsd, u_int32_t **tl, struct mbuf **md, caddr_t *dpos) { - int error; int fhlen; if (nfsd->nd_flag & ND_NFSV3) { - error = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (error) - return error; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; fhlen = fxdr_unsigned(int, **tl); if (fhlen != 0 && fhlen != NFSX_V3FH) return EBADRPC; @@ -1298,9 +1295,9 @@ nfsm_srvmtofh_xx(fhandle_t *f, struct nfsrv_descript *nfsd, fhlen = NFSX_V2FH; } if (fhlen != 0) { - error = nfsm_dissect_xx((void **)tl, fhlen, md, dpos); - if (error) - return error; + *tl = nfsm_dissect_xx(fhlen, md, dpos); + if (*tl == NULL) + return EBADRPC; bcopy((caddr_t)*tl, (caddr_t)(f), fhlen); } else { bzero((caddr_t)(f), NFSX_V3FH); @@ -1312,69 +1309,65 @@ int nfsm_srvsattr_xx(struct vattr *a, u_int32_t **tl, struct mbuf **md, caddr_t *dpos) { - int error = 0; - error = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (error) - goto bugout; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; if (**tl == nfs_true) { - error = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (error) - goto bugout; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; (a)->va_mode = nfstov_mode(**tl); } - error = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (error) - goto bugout; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; if (**tl == nfs_true) { - error = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (error) - goto bugout; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; (a)->va_uid = fxdr_unsigned(uid_t, **tl); } - error = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (error) - goto bugout; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; if (**tl == nfs_true) { - error = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (error) - goto bugout; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; (a)->va_gid = fxdr_unsigned(gid_t, **tl); } - error = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (error) - goto bugout; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; if (**tl == nfs_true) { - error = nfsm_dissect_xx((void **)tl, 2 * NFSX_UNSIGNED, - md, dpos); - if (error) - goto bugout; + *tl = nfsm_dissect_xx(2 * NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; (a)->va_size = fxdr_hyper(*tl); } - error = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (error) - goto bugout; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; switch (fxdr_unsigned(int, **tl)) { case NFSV3SATTRTIME_TOCLIENT: - error = nfsm_dissect_xx((void **)tl, 2 * NFSX_UNSIGNED, - md, dpos); - if (error) - goto bugout; + *tl = nfsm_dissect_xx(2 * NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; fxdr_nfsv3time(*tl, &(a)->va_atime); break; case NFSV3SATTRTIME_TOSERVER: getnanotime(&(a)->va_atime); break; } - error = nfsm_dissect_xx((void **)tl, NFSX_UNSIGNED, md, dpos); - if (error) - goto bugout; + *tl = nfsm_dissect_xx(NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; switch (fxdr_unsigned(int, **tl)) { case NFSV3SATTRTIME_TOCLIENT: - error = nfsm_dissect_xx((void **)tl, 2 * NFSX_UNSIGNED, - md, dpos); - if (error) - goto bugout; + *tl = nfsm_dissect_xx(2 * NFSX_UNSIGNED, md, dpos); + if (*tl == NULL) + return EBADRPC; fxdr_nfsv3time(*tl, &(a)->va_mtime); break; case NFSV3SATTRTIME_TOSERVER: @@ -1382,9 +1375,6 @@ nfsm_srvsattr_xx(struct vattr *a, break; } return 0; - -bugout: - return error; } void |