From 0fecd488295632b22c31d2e01132fe0651cb5b0d Mon Sep 17 00:00:00 2001 From: Todd Gill Date: Wed, 10 Feb 2021 12:03:33 -0500 Subject: [PATCH] coverity: check return value from dup2 and log error on failure Signed-off-by: Todd Gill --- src/resource/worker-control.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/resource/worker-control.c b/src/resource/worker-control.c index 125ae010..b1b77829 100644 --- a/src/resource/worker-control.c +++ b/src/resource/worker-control.c @@ -539,7 +539,10 @@ static int _setup_channel(sid_resource_t *owner, const char *alt_id, bool is_wor } if (chan->spec->wire.ext.used && chan->spec->wire.ext.pipe.fd_redir >= 0) { - dup2(chan->fd, chan->spec->wire.ext.pipe.fd_redir); + if (dup2(chan->fd, chan->spec->wire.ext.pipe.fd_redir) < 0) { + log_error_errno(id, errno, "Failed to redirect FD %d through channel %s : WORKER_WIRE_SOCKET", + chan->spec->wire.ext.pipe.fd_redir, chan->spec->id); + } close(chan->fd); } break;