From d2eaf8dc65702872e9ad8f44cd7c24fbc3fcb944 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 30 Jun 2023 13:30:45 +0000 Subject: [PATCH] jail: Initialize all file descriptors with -1 It is not a good idea to use zero as that might be a valid fd. Signed-off-by: Michael Tremer --- src/libpakfire/jail.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libpakfire/jail.c b/src/libpakfire/jail.c index a7f22b5fb..fbdf7b3c5 100644 --- a/src/libpakfire/jail.c +++ b/src/libpakfire/jail.c @@ -670,7 +670,7 @@ static int pakfire_jail_get_pipe_to_read(struct pakfire_jail* jail, int (*fds)[2 // Close the write end of the pipe if (*fd_write) { close(*fd_write); - *fd_write = 0; + *fd_write = -1; } // Return the read end @@ -685,7 +685,7 @@ static int pakfire_jail_get_pipe_to_write(struct pakfire_jail* jail, int (*fds)[ // Close the read end of the pipe if (*fd_read) { close(*fd_read); - *fd_read = 0; + *fd_read = -1; } // Return the write end @@ -731,7 +731,7 @@ static int pakfire_jail_wait(struct pakfire_jail* jail, struct pakfire_jail_exec int fd = fds[i]; // Skip fds which were not initialized - if (fd <= 0) + if (fd < 0) continue; ev.events = EPOLLHUP; @@ -1712,9 +1712,9 @@ static int __pakfire_jail_exec(struct pakfire_jail* jail, const char* argv[], .flags = flags, .pipes = { - .stdin = { 0, 0 }, - .stdout = { 0, 0 }, - .stderr = { 0, 0 }, + .stdin = { -1, -1 }, + .stdout = { -1, -1 }, + .stderr = { -1, -1 }, }, .communicate = { @@ -1722,6 +1722,8 @@ static int __pakfire_jail_exec(struct pakfire_jail* jail, const char* argv[], .out = communicate_out, .data = data, }, + + .pidfd = -1, }; DEBUG(jail->pakfire, "Executing jail...\n"); -- 2.39.5