[lxc-devel] [PATCH 5/6] coverity: Check fcntl return value

Stéphane Graber stgraber at ubuntu.com
Fri Feb 14 21:33:08 UTC 2014


Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 src/lxc/attach.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/lxc/attach.c b/src/lxc/attach.c
index 28cf916..a59dae3 100644
--- a/src/lxc/attach.c
+++ b/src/lxc/attach.c
@@ -1026,8 +1026,11 @@ static int attach_child_main(void* data)
 		flags = fcntl(fd, F_GETFL);
 		if (flags < 0)
 			continue;
-		if (flags & FD_CLOEXEC)
-			fcntl(fd, F_SETFL, flags & ~FD_CLOEXEC);
+		if (flags & FD_CLOEXEC) {
+			if (fcntl(fd, F_SETFL, flags & ~FD_CLOEXEC) < 0) {
+				SYSERROR("Unable to clear CLOEXEC from fd");
+			}
+		}
 	}
 
 	/* we're done, so we can now do whatever the user intended us to do */
-- 
1.9.rc1



More information about the lxc-devel mailing list