diff options
author | Elliott Hughes <enh@google.com> | 2019-07-24 16:00:58 -0700 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-07-24 19:38:45 -0500 |
commit | 6bf1360b72816b3ddc95b33de1bb111d718399b1 (patch) | |
tree | 68e61a4ed230cd65c9a5480b374ac04113f231c5 | |
parent | 8f5e168584bff66cf0d6645ad2eb36e8884ac396 (diff) | |
download | toybox-6bf1360b72816b3ddc95b33de1bb111d718399b1.tar.gz |
Avoid double-close of fd in loopfiles_lines.
Test: no EBADF in `strace -e close ./toybox tac /proc/version`
-rw-r--r-- | lib/lib.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -694,7 +694,8 @@ static void loopfile_lines_bridge(int fd, char *name) void loopfiles_lines(char **argv, void (*function)(char **pline, long len)) { do_lines_bridge = function; - loopfiles(argv, loopfile_lines_bridge); + // No O_CLOEXEC because we need to call fclose. + loopfiles_rw(argv, O_RDONLY|WARN_ONLY, 0, loopfile_lines_bridge); } // Slow, but small. |