From c009cd3289e9c377d3b702b0ae8b7957f53cd800 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Fri, 13 Sep 2019 12:41:46 -0700 Subject: [PATCH] Handle failure of fcntl in Pipe. (Coverity 1241934, 1241935) --- src/Pipe.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Pipe.cc b/src/Pipe.cc index 3775ca705d..0fa0eefdd7 100644 --- a/src/Pipe.cc +++ b/src/Pipe.cc @@ -19,13 +19,15 @@ static void pipe_fail(int eno) static void set_flags(int fd, int flags) { if ( flags ) - fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | flags); + if ( fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | flags) == -1 ) + pipe_fail(errno); } static void set_status_flags(int fd, int flags) { if ( flags ) - fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | flags); + if ( fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | flags) == -1 ) + pipe_fail(errno); } static int dup_or_fail(int fd, int flags)