aboutsummaryrefslogtreecommitdiff
path: root/bin/chmod
diff options
context:
space:
mode:
authorBryan Drewery <bdrewery@FreeBSD.org>2020-12-08 23:38:26 +0000
committerBryan Drewery <bdrewery@FreeBSD.org>2020-12-08 23:38:26 +0000
commit2dfa4b66b3d0caaaae6ce2df476b5615f8415a19 (patch)
tree550fa72fe4f1d83dfdc72e6db29170e0e6940f77 /bin/chmod
parentf1b18a668deb2aab9e2da908a403d58bce029d80 (diff)
downloadsrc-2dfa4b66b3d0caaaae6ce2df476b5615f8415a19.tar.gz
src-2dfa4b66b3d0caaaae6ce2df476b5615f8415a19.zip
fts_read: Handle error from a NULL return better.
This is addressing cases such as fts_read(3) encountering an [EIO] from fchdir(2) when FTS_NOCHDIR is not set. That would otherwise be seen as a successful traversal in some of these cases while silently discarding expected work. As noted in r264201, fts_read() does not set errno to 0 on a successful EOF so it needs to be set before calling it. Otherwise we might see a random error from one of the iterations. gzip is ignoring most errors and could be improved separately. Reviewed by: vangyzen Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D27184
Notes
Notes: svn path=/head/; revision=368467
Diffstat (limited to 'bin/chmod')
-rw-r--r--bin/chmod/chmod.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/bin/chmod/chmod.c b/bin/chmod/chmod.c
index 07b7c37312d5..e8657af0d97b 100644
--- a/bin/chmod/chmod.c
+++ b/bin/chmod/chmod.c
@@ -164,7 +164,7 @@ done: argv += optind;
if ((ftsp = fts_open(++argv, fts_options, 0)) == NULL)
err(1, "fts_open");
- for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
+ for (rval = 0; errno = 0, (p = fts_read(ftsp)) != NULL;) {
int atflag;
if ((fts_options & FTS_LOGICAL) ||