From: Michael Tremer Date: Mon, 17 Jul 2023 16:45:20 +0000 (+0000) Subject: jail: Fix file descriptor check X-Git-Tag: 0.9.29~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bca69274dd2b3c6b534fbfce324a472f3e937e56;p=pakfire.git jail: Fix file descriptor check Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/jail.c b/src/libpakfire/jail.c index db37cf7df..768c030c5 100644 --- a/src/libpakfire/jail.c +++ b/src/libpakfire/jail.c @@ -1686,7 +1686,7 @@ static int pakfire_jail_child(struct pakfire_jail* jail, struct pakfire_jail_exe #endif /* ENABLE_DEBUG */ // Connect standard input - if (ctx->pipes.stdin[0]) { + if (ctx->pipes.stdin[0] >= 0) { r = dup2(ctx->pipes.stdin[0], STDIN_FILENO); if (r < 0) { ERROR(jail->pakfire, "Could not connect fd %d to stdin: %m\n", @@ -1697,7 +1697,7 @@ static int pakfire_jail_child(struct pakfire_jail* jail, struct pakfire_jail_exe } // Connect standard output and error - if (ctx->pipes.stdout[1] && ctx->pipes.stderr[1]) { + if (ctx->pipes.stdout[1] >= 0 && ctx->pipes.stderr[1] >= 0) { r = dup2(ctx->pipes.stdout[1], STDOUT_FILENO); if (r < 0) { ERROR(jail->pakfire, "Could not connect fd %d to stdout: %m\n",