cronie/bug-786096_cronie-fdleak.diff

26 lines
792 B
Diff

Index: cronie-1.4.8/src/do_command.c
===================================================================
--- cronie-1.4.8.orig/src/do_command.c
+++ cronie-1.4.8/src/do_command.c
@@ -69,6 +69,7 @@ static int child_process(entry * e, user
int stdin_pipe[2], stdout_pipe[2];
char *input_data, *usernm, *mailto, *mailfrom;
int children = 0;
+ int i = 3, open_max = -1;
pid_t pid = getpid();
struct sigaction sa;
@@ -154,6 +155,12 @@ static int child_process(entry * e, user
*p = '\0';
}
+ open_max = sysconf(_SC_OPEN_MAX);
+ if (open_max < 0)
+ open_max = 1024;
+ for (i = STDERR + 1; i < open_max; ++i)
+ close(i);
+
/* fork again, this time so we can exec the user's command.
*/