From owner-freebsd-current Sun Jun 17 22:43:16 2001 Delivered-To: freebsd-current@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id BAFF537B41F for ; Sun, 17 Jun 2001 22:43:05 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id PAA27911; Mon, 18 Jun 2001 15:42:11 +1000 Date: Mon, 18 Jun 2001 15:40:23 +1000 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Matt Dillon Cc: "Andrey A. Chernov" , Garance A Drosihn , Jordan Hubbard , 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]) In-Reply-To: <200106180149.f5I1nma09752@earth.backplane.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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