mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/supervisor-coverity-fixes'
* origin/topic/jsiwek/supervisor-coverity-fixes: Fix leaked FDs in redirecting supervised node stdout/stderr Add checks for failed fcntl calls Set Pipe file descriptor flags correctly
This commit is contained in:
commit
c5b2659b6b
4 changed files with 23 additions and 3 deletions
7
CHANGES
7
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
|
3.1.0-dev.465 | 2020-01-29 11:45:15 -0800
|
||||||
|
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
3.1.0-dev.465
|
3.1.0-dev.469
|
||||||
|
|
13
src/Pipe.cc
13
src/Pipe.cc
|
@ -24,6 +24,9 @@ static int set_flags(int fd, int flags)
|
||||||
{
|
{
|
||||||
auto rval = fcntl(fd, F_GETFD);
|
auto rval = fcntl(fd, F_GETFD);
|
||||||
|
|
||||||
|
if ( rval == -1 )
|
||||||
|
pipe_fail(errno);
|
||||||
|
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
rval |= flags;
|
rval |= flags;
|
||||||
|
@ -39,6 +42,9 @@ static int unset_flags(int fd, int flags)
|
||||||
{
|
{
|
||||||
auto rval = fcntl(fd, F_GETFD);
|
auto rval = fcntl(fd, F_GETFD);
|
||||||
|
|
||||||
|
if ( rval == -1 )
|
||||||
|
pipe_fail(errno);
|
||||||
|
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
rval &= ~flags;
|
rval &= ~flags;
|
||||||
|
@ -54,6 +60,9 @@ static int set_status_flags(int fd, int flags)
|
||||||
{
|
{
|
||||||
auto rval = fcntl(fd, F_GETFL);
|
auto rval = fcntl(fd, F_GETFL);
|
||||||
|
|
||||||
|
if ( rval == -1 )
|
||||||
|
pipe_fail(errno);
|
||||||
|
|
||||||
if ( flags )
|
if ( flags )
|
||||||
{
|
{
|
||||||
rval |= flags;
|
rval |= flags;
|
||||||
|
@ -92,8 +101,8 @@ Pipe::Pipe(int flags0, int flags1, int status_flags0, int status_flags1,
|
||||||
pipe_fail(errno);
|
pipe_fail(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
flags[0] = set_flags(fds[0], flags[0]);
|
flags[0] = set_flags(fds[0], flags0);
|
||||||
flags[1] = set_flags(fds[1], flags[1]);
|
flags[1] = set_flags(fds[1], flags1);
|
||||||
status_flags[0] = set_status_flags(fds[0], status_flags0);
|
status_flags[0] = set_status_flags(fds[0], status_flags0);
|
||||||
status_flags[1] = set_status_flags(fds[1], status_flags1);
|
status_flags[1] = set_status_flags(fds[1], status_flags1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1241,6 +1241,8 @@ void Supervisor::SupervisedNode::Init(zeek::Options* options) const
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
safe_close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config.stdout_file )
|
if ( config.stdout_file )
|
||||||
|
@ -1256,6 +1258,8 @@ void Supervisor::SupervisedNode::Init(zeek::Options* options) const
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
safe_close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config.cpu_affinity )
|
if ( config.cpu_affinity )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue