X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/028ca06409743c9404b031313ae8c97b5dede721..027af0d8a477a7957c6246d0288edc69c6271727:/sys/kern/vfs_lookup.c diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index ce20836856..ccbdd33330 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -1,3 +1,10 @@ +/* + * Copyright (c) UNIX System Laboratories, Inc. All or some portions + * of this file are derived from material licensed to the + * University of California by American Telephone and Telegraph Co. + * or UNIX System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + */ /* * Copyright (c) 1982, 1986, 1989 Regents of the University of California. * All rights reserved. @@ -31,7 +38,7 @@ * SUCH DAMAGE. * * from: @(#)vfs_lookup.c 7.32 (Berkeley) 5/21/91 - * $Id: vfs_lookup.c,v 1.4 1993/11/07 21:44:48 wollman Exp $ + * $Id: vfs_lookup.c,v 1.8 1994/05/26 04:40:05 ache Exp $ */ #include "param.h" @@ -99,6 +106,13 @@ namei(ndp, p) else error = copyinstr(ndp->ni_dirp, ndp->ni_pnbuf, MAXPATHLEN, (u_int *)&ndp->ni_pathlen); +#if 0 + /* + * Don't allow empty pathname. + */ + if (!error && *ndp->ni_pnbuf == '\0') + error = ENOENT; +#endif if (error) { free(ndp->ni_pnbuf, M_NAMEI); ndp->ni_vp = NULL; @@ -277,10 +291,10 @@ dirloop: * responsibility for freeing the pathname buffer. */ ndp->ni_hash = 0; - for (cp = ndp->ni_ptr; *cp != 0 && *cp != '/'; cp++) + for (cp = ndp->ni_ptr; *cp != '\0' && *cp != '/'; cp++) ndp->ni_hash += (unsigned char)*cp; ndp->ni_namelen = cp - ndp->ni_ptr; - if (ndp->ni_namelen >= NAME_MAX) { + if (ndp->ni_namelen > NAME_MAX) { error = ENAMETOOLONG; goto bad; } @@ -360,7 +374,7 @@ dirloop: printf("not found\n"); #endif if (flag == LOOKUP || flag == DELETE || - error != ENOENT || *cp != 0) + error != ENOENT || *cp != '\0') goto bad; /* * If creating and at end of pathname, then can consider