summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2020-07-06 00:51:52 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2020-07-06 00:51:52 +0000
commit8ae9abf48d9711974aed8f310cf550932450d908 (patch)
tree38552ebb6fb8ff4a30998aedee1a8010f025b6de /bin
parent7625ba0da2ed495de65f47f028fe7a6bb9f83032 (diff)
Fix skipping of directories that begin with a '.' in -R mode.
It is not enough to avoid displaying the contents of the directory, we need to set FTS_SKIP to avoid descending into any subdirs too. Otherwise, if a ".foo" directory has a subdirectory "bar", ls will descend into bar and display its contents. OK deraadt@
Diffstat (limited to 'bin')
-rw-r--r--bin/ls/ls.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index d7bef994aeb..d8fb2e2182c 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ls.c,v 1.51 2018/09/13 15:23:32 millert Exp $ */
+/* $OpenBSD: ls.c,v 1.52 2020/07/06 00:51:51 millert Exp $ */
/* $NetBSD: ls.c,v 1.18 1996/07/09 09:16:29 mycroft Exp $ */
/*
@@ -369,8 +369,10 @@ traverse(int argc, char *argv[], int options)
switch (p->fts_info) {
case FTS_D:
if (p->fts_name[0] == '.' &&
- p->fts_level != FTS_ROOTLEVEL && !f_listdot)
+ p->fts_level != FTS_ROOTLEVEL && !f_listdot) {
+ (void)fts_set(ftsp, p, FTS_SKIP);
break;
+ }
/*
* If already output something, put out a newline as