Source: cctools Version: 3.5.1-2 Severity: important Tags: patch User: [email protected] Usertags: fcntl-fd-cloexec
Hi! This package contains code that tries to set the FD_CLOEXEC flag for a file descriptor, but it does using F_SETFL instead of F_SETFD. Using that value on F_SETFL is just wrong, and might make the call fail on some systems, as it's requesting to set an undetermined flag. For example on GNU/* FD_CLOEXEC has value 1, which matches with O_WRONLY. This will cause the code to at least leak file descriptors, and at worst to terminate execution. Attached a patch fixing this. Thanks, Guillem
From e89fd6c70faa43c623738596749402242b2770d0 Mon Sep 17 00:00:00 2001 From: Guillem Jover <[email protected]> Date: Tue, 18 Dec 2012 17:30:06 +0100 Subject: [PATCH] cctools: Set FD_CLOEXEC correctly using F_SETFD not F_SETFL Using that value on F_SETFL is just wrong, and might make the call fail on some systems, as it's requesting to set an undetermined flag. For example on GNU/* FD_CLOEXEC has value 1, which matches with O_WRONLY. This might cause the code to at least leak file descriptors, and at worst to terminate execution. --- ftsh/src/timed_exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftsh/src/timed_exec.c b/ftsh/src/timed_exec.c index 2c0cd44..bdac7b2 100644 --- a/ftsh/src/timed_exec.c +++ b/ftsh/src/timed_exec.c @@ -60,7 +60,7 @@ timed_exec_t timed_exec( int line, const char *path, char **argv, int fds[3], pi /* Set the pipe to automatically close after exec. */ - if( fcntl(pfds[1],F_SETFL,FD_CLOEXEC)==0 ) { + if( fcntl(pfds[1],F_SETFD,FD_CLOEXEC)==0 ) { setsid(); execvp(path,argv); } -- 1.8.1.rc0

