mirror of
https://github.com/troglobit/finit.git
synced 2026-11-01 13:10:32 +00:00
run_interactive(): Fix a potential file descriptor leak.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
939cfc2476
commit
def759fe41
1 file changed
+2
-1
@@ -502,7 +502,7 @@ int run_interactive(char *cmd, char *fmt, ...)
|
|||||||
int status, oldout = 1, olderr = 2;
|
int status, oldout = 1, olderr = 2;
|
||||||
char line[LINE_SIZE];
|
char line[LINE_SIZE];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
FILE *fp = tmpfile();
|
FILE *fp;
|
||||||
|
|
||||||
if (!cmd) {
|
if (!cmd) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
@@ -518,6 +518,7 @@ int run_interactive(char *cmd, char *fmt, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Redirect output from cmd to a tempfile */
|
/* Redirect output from cmd to a tempfile */
|
||||||
|
fp = tmpfile();
|
||||||
if (fp && !debug) {
|
if (fp && !debug) {
|
||||||
oldout = dup(STDOUT_FILENO);
|
oldout = dup(STDOUT_FILENO);
|
||||||
olderr = dup(STDERR_FILENO);
|
olderr = dup(STDERR_FILENO);
|
||||||
|
|||||||
Reference in new issue
Block a user