[lxc-devel] [PATCH 2/7] coverity: Check return value of fcntl in lxc_popen

Stéphane Graber stgraber at ubuntu.com
Wed Feb 12 21:45:51 UTC 2014


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

diff --git a/src/lxc/utils.c b/src/lxc/utils.c
index b7a29cb..90401a5 100644
--- a/src/lxc/utils.c
+++ b/src/lxc/utils.c
@@ -642,7 +642,10 @@ extern struct lxc_popen_FILE *lxc_popen(const char *command)
 			 * But it must not be marked close-on-exec.
 			 * Undo the effects.
 			 */
-			fcntl(child_end, F_SETFD, 0);
+			if (fcntl(child_end, F_SETFD, 0) != 0) {
+				SYSERROR("Failed to remove FD_CLOEXEC from fd.");
+				exit(127);
+			}
 		}
 
 		/*
-- 
1.9.rc1



More information about the lxc-devel mailing list