svn commit: r199137 - head/sys/kern
Konstantin Belousov
kib at FreeBSD.org
Tue Nov 10 11:50:37 UTC 2009
Author: kib
Date: Tue Nov 10 11:50:37 2009
New Revision: 199137
URL: http://svn.freebsd.org/changeset/base/199137
Log:
When rename("a", "b/.") is performed, target namei() call returns
dvp == vp. Rename syscall does not check for the case, and at least
ufs_rename() cannot deal with it. POSIX explicitely requires that both
rename(2) and rmdir(2) return EINVAL when any of the pathes end in "/.".
Detect the slashdot lookup for RENAME or REMOVE in lookup(), and return
EINVAL.
Reported by: Jim Meyering <jim meyering net>
Tested by: simon, pho
MFC after: 1 week
Modified:
head/sys/kern/vfs_lookup.c
Modified: head/sys/kern/vfs_lookup.c
==============================================================================
--- head/sys/kern/vfs_lookup.c Tue Nov 10 11:46:53 2009 (r199136)
+++ head/sys/kern/vfs_lookup.c Tue Nov 10 11:50:37 2009 (r199137)
@@ -552,6 +552,12 @@ dirloop:
else
cnp->cn_flags &= ~ISLASTCN;
+ if ((cnp->cn_flags & ISLASTCN) != 0 &&
+ cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.' &&
+ (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) {
+ error = EINVAL;
+ goto bad;
+ }
/*
* Check for degenerate name (e.g. / or "")
More information about the svn-src-head
mailing list