[vlc-devel] commit: Set close-on-exec file for file inputs ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sat Oct 11 19:36:41 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sat Oct 11 20:11:08 2008 +0300| [90ba04f49ebbaccf9efafe93b3975bf18a236418] | committer: Rémi Denis-Courmont
Set close-on-exec file for file inputs
We don't want to leak descriptors to child PROCESSES (!= threads) such
as the pseudo-CGI interface. The socket wrappers ahve already been doing
that for a while. Unfortunately, there are still many "leaks", through
underlying libraries, opendir(), fopen(), etc. And then, this is not
thread-safe (we leak if another thread calls fork() between open() and
fcntl()). This is a well-known limitation in POSIX anyway.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=90ba04f49ebbaccf9efafe93b3975bf18a236418
---
modules/access/file.c | 1 +
modules/access/mmap.c | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/modules/access/file.c b/modules/access/file.c
index bd195d5..70a50c5 100644
--- a/modules/access/file.c
+++ b/modules/access/file.c
@@ -349,6 +349,7 @@ static int open_file (access_t *p_access, const char *path)
_("VLC could not open the file \"%s\"."), path);
return -1;
}
+ fcntl (fd, F_SETFD, fcntl (fd, F_GETFD) | FD_CLOEXEC);
#if defined(HAVE_FCNTL_H)
/* We'd rather use any available memory for reading ahead
diff --git a/modules/access/mmap.c b/modules/access/mmap.c
index eb551ab..823e6d4 100644
--- a/modules/access/mmap.c
+++ b/modules/access/mmap.c
@@ -104,6 +104,7 @@ static int Open (vlc_object_t *p_this)
msg_Warn (p_access, "cannot open %s: %m", path);
goto error;
}
+ fcntl (fd, F_SETFD, fcntl (fd, F_GETFD) | FD_CLOEXEC);
/* mmap() is only safe for regular and block special files.
* For other types, it may be some idiosyncrasic interface (e.g. packet
More information about the vlc-devel
mailing list