diff --git a/CHANGES b/CHANGES index d4709e651a..28865a4997 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +3.1.0-dev.469 | 2020-01-30 08:44:15 -0700 + + * Fix leaked FDs in redirecting supervised node stdout/stderr (Jon Siwek, Corelight) + + * Add checks for failed fcntl calls (Jon Siwek, Corelight) + + * Set Pipe file descriptor flags correctly (Jon Siwek, Corelight) 3.1.0-dev.465 | 2020-01-29 11:45:15 -0800 diff --git a/VERSION b/VERSION index a5151cef77..5e4be2dfc5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.0-dev.465 +3.1.0-dev.469 diff --git a/src/Pipe.cc b/src/Pipe.cc index 9957e25dce..5a0916a3dd 100644 --- a/src/Pipe.cc +++ b/src/Pipe.cc @@ -24,6 +24,9 @@ static int set_flags(int fd, int flags) { auto rval = fcntl(fd, F_GETFD); + if ( rval == -1 ) + pipe_fail(errno); + if ( flags ) { rval |= flags; @@ -39,6 +42,9 @@ static int unset_flags(int fd, int flags) { auto rval = fcntl(fd, F_GETFD); + if ( rval == -1 ) + pipe_fail(errno); + if ( flags ) { rval &= ~flags; @@ -54,6 +60,9 @@ static int set_status_flags(int fd, int flags) { auto rval = fcntl(fd, F_GETFL); + if ( rval == -1 ) + pipe_fail(errno); + if ( flags ) { rval |= flags; @@ -92,8 +101,8 @@ Pipe::Pipe(int flags0, int flags1, int status_flags0, int status_flags1, pipe_fail(errno); } - flags[0] = set_flags(fds[0], flags[0]); - flags[1] = set_flags(fds[1], flags[1]); + flags[0] = set_flags(fds[0], flags0); + flags[1] = set_flags(fds[1], flags1); status_flags[0] = set_status_flags(fds[0], status_flags0); status_flags[1] = set_status_flags(fds[1], status_flags1); } diff --git a/src/supervisor/Supervisor.cc b/src/supervisor/Supervisor.cc index 4d971a1068..4d41383a85 100644 --- a/src/supervisor/Supervisor.cc +++ b/src/supervisor/Supervisor.cc @@ -1241,6 +1241,8 @@ void Supervisor::SupervisedNode::Init(zeek::Options* options) const strerror(errno)); exit(1); } + + safe_close(fd); } if ( config.stdout_file ) @@ -1256,6 +1258,8 @@ void Supervisor::SupervisedNode::Init(zeek::Options* options) const strerror(errno)); exit(1); } + + safe_close(fd); } if ( config.cpu_affinity )