]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: fix error checking for dup2()
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 1 Feb 2021 13:51:41 +0000 (14:51 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 1 Feb 2021 13:51:41 +0000 (14:51 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c

index 3dc5b1a10059021699593f554c4dc675b0080a10..60666eebd9f61b0558025402eefee33dff4908ae 100644 (file)
@@ -1129,15 +1129,15 @@ __noreturn static void do_attach(struct attach_payload *ap)
         * may want to make sure the fds are closed, for example.
         */
        if (options->stdin_fd >= 0 && options->stdin_fd != STDIN_FILENO)
-               if (dup2(options->stdin_fd, STDIN_FILENO))
+               if (dup2(options->stdin_fd, STDIN_FILENO) < 0)
                        SYSDEBUG("Failed to replace stdin with %d", options->stdin_fd);
 
        if (options->stdout_fd >= 0 && options->stdout_fd != STDOUT_FILENO)
-               if (dup2(options->stdout_fd, STDOUT_FILENO))
+               if (dup2(options->stdout_fd, STDOUT_FILENO) < 0)
                        SYSDEBUG("Failed to replace stdout with %d", options->stdout_fd);
 
        if (options->stderr_fd >= 0 && options->stderr_fd != STDERR_FILENO)
-               if (dup2(options->stderr_fd, STDERR_FILENO))
+               if (dup2(options->stderr_fd, STDERR_FILENO) < 0)
                        SYSDEBUG("Failed to replace stderr with %d", options->stderr_fd);
 
        /* close the old fds */