Subject: Re: lib/3211: open allows a null path as an arg.
To: None <pjl@ilx.com>
From: Klaus Klein <kleink@layla.inka.de>
List: netbsd-bugs
Date: 02/11/1997 16:43:10
> Open allows a null string to be passed as the path argument, resulting
> in what appears to be the current directory. None of the other unixes
> that I tried this on allowed the call.

That's a bug I encountered when I started my POSIX work on NetBSD.
In general, POSIX.1 section 2.4 (pathname resolution) states:
"A null pathname is invalid.", so I simply added a short check:

*** vfs_lookup.c	1996/12/20 13:28:38	1.1.1.1
--- vfs_lookup.c	1997/02/05 20:56:26	1.1.1.1.2.1
***************
*** 111,116 ****
--- 111,123 ----
  	else
  		error = copyinstr(ndp->ni_dirp, cnp->cn_pnbuf,
  			    MAXPATHLEN, &ndp->ni_pathlen);
+ 
+ 	/*
+ 	 * POSIX.1: "" is not a legal name, so stop right here
+ 	 */      
+ 	if (!error && ndp->ni_pathlen == 1)
+ 		error = ENOENT ;
+ 
  	if (error) {
  		free(cnp->cn_pnbuf, M_NAMEI);
  		ndp->ni_vp = NULL;


-klaus