Commit 90ba04f4 authored by Rémi Denis-Courmont's avatar 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.
parent e95a471c
...@@ -349,6 +349,7 @@ static int open_file (access_t *p_access, const char *path) ...@@ -349,6 +349,7 @@ static int open_file (access_t *p_access, const char *path)
_("VLC could not open the file \"%s\"."), path); _("VLC could not open the file \"%s\"."), path);
return -1; return -1;
} }
fcntl (fd, F_SETFD, fcntl (fd, F_GETFD) | FD_CLOEXEC);
#if defined(HAVE_FCNTL_H) #if defined(HAVE_FCNTL_H)
/* We'd rather use any available memory for reading ahead /* We'd rather use any available memory for reading ahead
......
...@@ -104,6 +104,7 @@ static int Open (vlc_object_t *p_this) ...@@ -104,6 +104,7 @@ static int Open (vlc_object_t *p_this)
msg_Warn (p_access, "cannot open %s: %m", path); msg_Warn (p_access, "cannot open %s: %m", path);
goto error; goto error;
} }
fcntl (fd, F_SETFD, fcntl (fd, F_GETFD) | FD_CLOEXEC);
/* mmap() is only safe for regular and block special files. /* mmap() is only safe for regular and block special files.
* For other types, it may be some idiosyncrasic interface (e.g. packet * For other types, it may be some idiosyncrasic interface (e.g. packet
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment