From bca69274dd2b3c6b534fbfce324a472f3e937e56 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 17 Jul 2023 16:45:20 +0000 Subject: [PATCH] jail: Fix file descriptor check Signed-off-by: Michael Tremer --- src/libpakfire/jail.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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", -- 2.47.3