diff options
author | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2006-12-06 17:49:59 +0000 |
---|---|---|
committer | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2006-12-06 17:49:59 +0000 |
commit | 5ed98d69f5f0c903cb986375e79f8315b0a4922e (patch) | |
tree | fd60fe53f039d25df92872c03f79ae0540a923db /sys/nfs | |
parent | 9a7634536d89db3472b5d5431115497ae2c7caee (diff) |
nfs_readdirplusrpc():
Replace the pointer aerobics used to construct the
namecache hash with a more saner approach since the
former could lead to a null deref (PR5305).
Also make sure that the current buf is bigenough
before caching the current entry.
comments&ok pedro@
Diffstat (limited to 'sys/nfs')
-rw-r--r-- | sys/nfs/nfs_vnops.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 30f21cb12b6..cf5a57cf63e 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_vnops.c,v 1.67 2006/04/26 21:37:37 pedro Exp $ */ +/* $OpenBSD: nfs_vnops.c,v 1.68 2006/12/06 17:49:58 thib Exp $ */ /* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */ /* @@ -58,6 +58,7 @@ #include <sys/dirent.h> #include <sys/fcntl.h> #include <sys/lockf.h> +#include <sys/hash.h> #include <uvm/uvm_extern.h> @@ -2401,7 +2402,7 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred, newvp = NFSTOV(np); } } - if (doit) { + if (doit && bigenough) { dpossav2 = dpos; dpos = dpossav1; mdsav2 = md; @@ -2411,13 +2412,14 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred, md = mdsav2; dp->d_type = IFTODT(VTTOIF(np->n_vattr.va_type)); - ndp->ni_vp = newvp; - cnp->cn_hash = 0; - for (cp = cnp->cn_nameptr, i = 1; i <= len; - i++, cp++) - cnp->cn_hash += (unsigned char)*cp * i; - if (cnp->cn_namelen <= NCHNAMLEN) - cache_enter(ndp->ni_dvp, ndp->ni_vp, cnp); + if (cnp->cn_namelen <= NCHNAMLEN) { + ndp->ni_vp = newvp; + cnp->cn_hash = + hash32_str(cnp->cn_nameptr, + HASHINIT); + cache_enter(ndp->ni_dvp, ndp->ni_vp, + cnp); + } } } else { /* Just skip over the file handle */ |