Date: Mon, 18 Jun 2001 15:40:23 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Matt Dillon <dillon@earth.backplane.com> Cc: "Andrey A. Chernov" <ache@nagual.pp.ru>, Garance A Drosihn <drosih@rpi.edu>, Jordan Hubbard <jkh@osd.bsdi.com>, imp@harmony.village.org, steveo@eircom.net, david@catwhisker.org, current@FreeBSD.ORG Subject: Re: Ok, try this patch. (was Re: symlink(2) [Was: Re: tcsh.cat]) Message-ID: <Pine.BSF.4.21.0106181454450.6291-100000@besplex.bde.org> In-Reply-To: <200106180149.f5I1nma09752@earth.backplane.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 17 Jun 2001, Matt Dillon wrote: > Ok, this patch should do it. For review. I've made it return ENOENT, > which is the same error that is returned when you try to open an empty > path (e.g. open("", ...)). > > (Note: This is unrelated to Bruce's second issue with 'cp' copying > symlinks that don't exist, which is a cp-specific). > > If nobody has any objections I will commit this to -current on wednesday > and MFC it next saturday. > > Index: vfs_lookup.c > =================================================================== > RCS file: /home/ncvs/src/sys/kern/vfs_lookup.c,v > retrieving revision 1.38.2.2 > diff -u -r1.38.2.2 vfs_lookup.c > --- vfs_lookup.c 2001/05/20 12:11:57 1.38.2.2 > +++ vfs_lookup.c 2001/06/18 01:39:46 > @@ -200,6 +200,12 @@ > break; > } > linklen = MAXPATHLEN - auio.uio_resid; > + if (linklen == 0) { > + if (ndp->ni_pathlen > 1) > + zfree(namei_zone, cp); > + error = ENOENT; > + break; > + } > if (linklen + ndp->ni_pathlen >= MAXPATHLEN) { > if (ndp->ni_pathlen > 1) > zfree(namei_zone, cp); NetBSD committed essentially this patch 4 years ago (as part of rev.1.23). I like it, except it seems to be incompatible with POSIX.1-200x. The bug that stat(2) on a null symlink classifies the target of the symlink as a directory is caused by resolving the pathname to "" and then not returning ENOENT in namei(). "" tends to be interpreted as "." unless it is specially disallowed, and that's what happens here. "" is only disallowed for the unresolved pathname. Since the bug is in namei(), it affects all syscalls that deal with pathnames. E.g., you can open() null symlinks; this is equivalent to opening ".". Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0106181454450.6291-100000>