diff options
author | Bryan Drewery <bdrewery@FreeBSD.org> | 2020-12-08 23:38:26 +0000 |
---|---|---|
committer | Bryan Drewery <bdrewery@FreeBSD.org> | 2020-12-08 23:38:26 +0000 |
commit | 2dfa4b66b3d0caaaae6ce2df476b5615f8415a19 (patch) | |
tree | 550fa72fe4f1d83dfdc72e6db29170e0e6940f77 /usr.bin/gzip | |
parent | f1b18a668deb2aab9e2da908a403d58bce029d80 (diff) | |
download | src-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 'usr.bin/gzip')
-rw-r--r-- | usr.bin/gzip/gzip.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/gzip/gzip.c b/usr.bin/gzip/gzip.c index 47cfd225b844..5128e7ed43e0 100644 --- a/usr.bin/gzip/gzip.c +++ b/usr.bin/gzip/gzip.c @@ -2075,7 +2075,7 @@ handle_dir(char *dir) return; } - while ((entry = fts_read(fts))) { + while (errno = 0, (entry = fts_read(fts))) { switch(entry->fts_info) { case FTS_D: case FTS_DP: @@ -2090,6 +2090,8 @@ handle_dir(char *dir) handle_file(entry->fts_path, entry->fts_statp); } } + if (errno != 0) + warn("error with fts_read %s", dir); (void)fts_close(fts); } #endif |