]> git.ipfire.org Git - pakfire.git/commitdiff
jail: Fix file descriptor check
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 17 Jul 2023 16:45:20 +0000 (16:45 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 17 Jul 2023 16:45:20 +0000 (16:45 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/jail.c

index db37cf7df80ed84642b0ba559e8a4039d8aea1f8..768c030c5c8f1c4a521a8f9511c0bebf45a70a46 100644 (file)
@@ -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",