Skip to content
Snippets Groups Projects
Commit 0361052a authored by Kevin P. Fleming's avatar Kevin P. Fleming
Browse files

ensure that file handles are never double closed

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6485 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 25f3403b
No related branches found
No related tags found
No related merge requests found
...@@ -302,9 +302,6 @@ static int app_exec(struct ast_channel *chan, void *data) ...@@ -302,9 +302,6 @@ static int app_exec(struct ast_channel *chan, void *data)
dup2(child_stdin[0], STDIN_FILENO); dup2(child_stdin[0], STDIN_FILENO);
dup2(child_stdout[1], STDOUT_FILENO); dup2(child_stdout[1], STDOUT_FILENO);
dup2(child_stderr[1], STDERR_FILENO); dup2(child_stderr[1], STDERR_FILENO);
close(child_stdin[1]);
close(child_stdout[0]);
close(child_stderr[0]);
for (i = STDERR_FILENO + 1; i < 1024; i++) for (i = STDERR_FILENO + 1; i < 1024; i++)
close(i); close(i);
execv(command, argv); execv(command, argv);
...@@ -323,8 +320,11 @@ static int app_exec(struct ast_channel *chan, void *data) ...@@ -323,8 +320,11 @@ static int app_exec(struct ast_channel *chan, void *data)
struct ast_channel *rchan; struct ast_channel *rchan;
close(child_stdin[0]); close(child_stdin[0]);
child_stdin[0] = 0;
close(child_stdout[1]); close(child_stdout[1]);
child_stdout[1] = 0;
close(child_stderr[1]); close(child_stderr[1]);
child_stderr[1] = 0;
if (!(child_events = fdopen(child_events_fd, "w"))) { if (!(child_events = fdopen(child_events_fd, "w"))) {
ast_chan_log(LOG_WARNING, chan, "Could not open stream for child events\n"); ast_chan_log(LOG_WARNING, chan, "Could not open stream for child events\n");
...@@ -505,20 +505,23 @@ static int app_exec(struct ast_channel *chan, void *data) ...@@ -505,20 +505,23 @@ static int app_exec(struct ast_channel *chan, void *data)
if (child_errors) if (child_errors)
fclose(child_errors); fclose(child_errors);
if (child_stdin[0]) { if (child_stdin[0])
close(child_stdin[0]); close(child_stdin[0]);
if (child_stdin[1])
close(child_stdin[1]); close(child_stdin[1]);
}
if (child_stdout[0]) { if (child_stdout[0])
close(child_stdout[0]); close(child_stdout[0]);
if (child_stdout[1])
close(child_stdout[1]); close(child_stdout[1]);
}
if (child_stderr[0]) { if (child_stderr[0])
close(child_stderr[0]); close(child_stderr[0]);
if (child_stderr[1])
close(child_stderr[1]); close(child_stderr[1]);
}
if (u) { if (u) {
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment