summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1996-11-06 06:51:46 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1996-11-06 06:51:46 +0000
commit26463d1fa7ab418419f0426ac8b6eed996718e3f (patch)
tree9980f493f60c0789c091a1835841086cd28cc4a6 /sys
parenta019be98c99080e3b3bdfd6e9721a95f1920d879 (diff)
Get vnode locking right when verifying pathnames ending in '/' are directories
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_lookup.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index 0bc7a79f6d8..7d3da31ddfa 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_lookup.c,v 1.4 1996/11/06 03:54:01 tholo Exp $ */
+/* $OpenBSD: vfs_lookup.c,v 1.5 1996/11/06 06:51:45 tholo Exp $ */
/* $NetBSD: vfs_lookup.c,v 1.17 1996/02/09 19:00:59 christos Exp $ */
/*
@@ -86,10 +86,7 @@ namei(ndp)
register struct vnode *dp; /* the directory we are searching */
struct iovec aiov; /* uio for reading symbolic links */
struct uio auio;
- int error, linklen;
-#if 0
- int dironly = 0;
-#endif
+ int error, linklen, dironly = 0;
struct componentname *cnp = &ndp->ni_cnd;
ndp->ni_cnd.cn_cred = ndp->ni_cnd.cn_proc->p_ucred;
@@ -132,7 +129,6 @@ namei(ndp)
return (error);
}
-#if 0
/*
* Ignore trailing /'s, except require the last path element
* to be a directory
@@ -148,7 +144,6 @@ namei(ndp)
cnp->cn_pnbuf[ndp->ni_pathlen - 2] == '/')
cnp->cn_pnbuf[--ndp->ni_pathlen - 1] = '\0';
}
-#endif
ndp->ni_loopcnt = 0;
@@ -183,19 +178,16 @@ namei(ndp)
* Check for symbolic link
*/
if ((cnp->cn_flags & ISSYMLINK) == 0) {
-#if 0
/*
* Check for directory if dironly
*/
if (dironly && ndp->ni_vp->v_type != VDIR) {
- if (cnp->cn_flags & LOCKPARENT)
+ if ((cnp->cn_flags & LOCKPARENT) && ndp->ni_pathlen == 1)
VOP_UNLOCK(ndp->ni_dvp);
- if (cnp->cn_flags & LOCKLEAF)
- VOP_UNLOCK(ndp->ni_vp);
- error = ENOTDIR;
- break;
+ vput(ndp->ni_vp);
+ FREE(cnp->cn_pnbuf, M_NAMEI);
+ return (ENOTDIR);
}
-#endif
if ((cnp->cn_flags & (SAVENAME | SAVESTART)) == 0)
FREE(cnp->cn_pnbuf, M_NAMEI);
else