aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-07-24 16:00:58 -0700
committerRob Landley <rob@landley.net>2019-07-24 19:38:45 -0500
commit6bf1360b72816b3ddc95b33de1bb111d718399b1 (patch)
tree68e61a4ed230cd65c9a5480b374ac04113f231c5
parent8f5e168584bff66cf0d6645ad2eb36e8884ac396 (diff)
downloadtoybox-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.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 47e5ca21..53962a59 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -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.