Date: Tue, 10 Nov 2009 11:50:37 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r199137 - head/sys/kern Message-ID: <200911101150.nAABobP6058139@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 "")
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911101150.nAABobP6058139>