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 [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to