Don't allow last path element to be nonexistant.
This commit is contained in:
parent
92be7f4643
commit
314b003dee
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: getcwd.c,v 1.38 2005/07/05 02:56:12 enami Exp $ */
|
||||
/* $NetBSD: getcwd.c,v 1.39 2005/08/13 19:53:53 elad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993, 1995
|
||||
|
@ -37,7 +37,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: getcwd.c,v 1.38 2005/07/05 02:56:12 enami Exp $");
|
||||
__RCSID("$NetBSD: getcwd.c,v 1.39 2005/08/13 19:53:53 elad Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -159,13 +159,6 @@ loop:
|
|||
* target to unresolved path.
|
||||
*/
|
||||
if (lstat(resolved, &sb) == -1) {
|
||||
/* Allow nonexistent component if this is the last one. */
|
||||
while (*q == '/')
|
||||
q++;
|
||||
if (*q == 0 && errno == ENOENT) {
|
||||
errno = serrno;
|
||||
return (resolved);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
if (S_ISLNK(sb.st_mode)) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: realpath.3,v 1.11 2003/08/07 16:42:55 agc Exp $
|
||||
.\" $NetBSD: realpath.3,v 1.12 2005/08/13 19:53:53 elad Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1994
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -32,7 +32,7 @@
|
|||
.\"
|
||||
.\" from: @(#)realpath.3 8.2 (Berkeley) 2/16/94
|
||||
.\"
|
||||
.Dd February 16, 1994
|
||||
.Dd August 13, 2005
|
||||
.Dt REALPATH 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -72,11 +72,6 @@ The
|
|||
function will resolve both absolute and relative paths
|
||||
and return the absolute pathname corresponding to
|
||||
.Fa pathname .
|
||||
All but the last component of
|
||||
.Fa pathname
|
||||
must exist when
|
||||
.Fn realpath
|
||||
is called.
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Fn realpath
|
||||
|
|
Loading…
Reference in New Issue