Subject: Re: lib/3211: open allows a null path as an arg.
To: Klaus Klein <kleink@layla.inka.de>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: netbsd-bugs
Date: 02/11/1997 14:01:19
On Tue, 11 Feb 1997 16:43:10 +0100 
 Klaus Klein <kleink@layla.inka.de> wrote:

 > 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:

...I agree we should make this change... However, I'd like to also
know how many programs this breaks :-/

Now...

 > *** 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 ;
 > + 

Hm, would a more obvious test be:

	if (!error && cnp->cn_pnbuf[0] == '\0')
		error = ENOENT;

?

 >   	if (error) {
 >   		free(cnp->cn_pnbuf, M_NAMEI);
 >   		ndp->ni_vp = NULL;
 > 
 > 
 > -klaus

Jason R. Thorpe                                       thorpej@nas.nasa.gov
NASA Ames Research Center                               Home: 408.866.1912
NAS: M/S 258-6                                          Work: 415.604.0935
Moffett Field, CA 94035                                Pager: 415.428.6939