mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-03 12:28:03 +02:00
Bug 15947: Close file descriptors before execing helper (Markus Rechberger)
* dbus/dbus-sysdeps-unix.c (_dbus_get_autolaunch_address): Close file descriptors before exec.
This commit is contained in:
parent
af41f085c6
commit
e2bc723206
1 changed files with 13 additions and 4 deletions
|
|
@ -2848,7 +2848,10 @@ _dbus_get_autolaunch_address (DBusString *address,
|
|||
if (pid == 0)
|
||||
{
|
||||
/* child process */
|
||||
int fd = open ("/dev/null", O_RDWR);
|
||||
int maxfds;
|
||||
int fd;
|
||||
|
||||
fd = open ("/dev/null", O_RDWR);
|
||||
if (fd == -1)
|
||||
/* huh?! can't open /dev/null? */
|
||||
_exit (1);
|
||||
|
|
@ -2869,9 +2872,15 @@ _dbus_get_autolaunch_address (DBusString *address,
|
|||
if (dup2 (errors_pipe[WRITE_END], 2) == -1)
|
||||
_exit (1);
|
||||
|
||||
close (fd);
|
||||
close (address_pipe[WRITE_END]);
|
||||
close (errors_pipe[WRITE_END]);
|
||||
maxfds = sysconf (_SC_OPEN_MAX);
|
||||
/* Pick something reasonable if for some reason sysconf
|
||||
* says unlimited.
|
||||
*/
|
||||
if (maxfds < 0)
|
||||
maxfds = 1024;
|
||||
/* close all inherited fds */
|
||||
for (i = 3; i < maxfds; i++)
|
||||
close (i);
|
||||
|
||||
execv (DBUS_BINDIR "/dbus-launch", argv);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue