diff options
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/fts.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index 5d9c8aae5be..b5c65e84b75 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fts.c,v 1.25 2001/05/15 21:14:39 millert Exp $ */ +/* $OpenBSD: fts.c,v 1.26 2001/05/30 20:40:30 millert Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; #else -static char rcsid[] = "$OpenBSD: fts.c,v 1.25 2001/05/15 21:14:39 millert Exp $"; +static char rcsid[] = "$OpenBSD: fts.c,v 1.26 2001/05/30 20:40:30 millert Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -271,6 +271,7 @@ fts_read(sp) FTS *sp; { FTSENT *p, *tmp; + struct stat sb; int instr; char *t; int saved_errno; @@ -443,8 +444,14 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent); return (NULL); } (void)close(p->fts_symfd); - } else if (!(p->fts_flags & FTS_DONTCHDIR)) { - if (CHDIR(sp, "..")) { + } else if (!(p->fts_flags & FTS_DONTCHDIR) && !ISSET(FTS_NOCHDIR)) { + if (chdir("..") || stat(".", &sb)) { + SET(FTS_STOP); + return (NULL); + } + if (sb.st_ino != p->fts_parent->fts_ino || + sb.st_dev != p->fts_parent->fts_dev) { + errno = ENOENT; SET(FTS_STOP); return (NULL); } |