diff options
author | 1996-12-23 06:08:59 +0000 | |
---|---|---|
committer | 1996-12-23 06:08:59 +0000 | |
commit | 8d77b1f3ee012f9215a998c5c591889adab747f6 (patch) | |
tree | 6d6094a1e4a6c309fbaf5da94ad537f1fa8eca90 /lib/libc | |
parent | Avoid spoofing when cd'ing to subdirs. First cut. (diff) | |
download | wireguard-openbsd-8d77b1f3ee012f9215a998c5c591889adab747f6.tar.xz wireguard-openbsd-8d77b1f3ee012f9215a998c5c591889adab747f6.zip |
Back out last change, it is not sufficient.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/fts.c | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index 99902818f32..dfb2a30039a 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: fts.c,v 1.3 1996/12/23 04:58:34 millert Exp $"; +static char rcsid[] = "$OpenBSD: fts.c,v 1.4 1996/12/23 06:08:59 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -336,30 +336,12 @@ fts_read(sp) * FTS_STOP or the fts_info field of the node. */ if (sp->fts_child) { - if (!ISSET(FTS_NOCHDIR)) { - struct stat *parent1, *fts_statp2, *parent2; - int ret; - - /* XXX - make readable somehow */ - if (!ISSET(FTS_NOSTAT) && !ISSET(FTS_LOGICAL)) - ret = ((lstat(".", parent1) != 0) || - (chdir(p->fts_accpath) != 0) || - (lstat(".", fts_statp2) != 0) || - (lstat("..", parent2) != 0) || - (p->fts_dev != fts_statp2->st_dev) || - (p->fts_ino != fts_statp2->st_ino) || - (parent1->st_dev != parent2->st_dev) || - (parent1->st_ino != parent2->st_ino)); - else - ret = chdir(p->fts_accpath); - - if (ret) { - p->fts_errno = errno; - p->fts_flags |= FTS_DONTCHDIR; - for (p = sp->fts_child; p; p = p->fts_link) - p->fts_accpath = - p->fts_parent->fts_accpath; - } + if (CHDIR(sp, p->fts_accpath)) { + p->fts_errno = errno; + p->fts_flags |= FTS_DONTCHDIR; + for (p = sp->fts_child; p; p = p->fts_link) + p->fts_accpath = + p->fts_parent->fts_accpath; } } else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) { if (ISSET(FTS_STOP)) |