jail: check return value when opening console
authorDaniel Golle <daniel@makrotopia.org>
Mon, 23 Aug 2021 16:47:23 +0000 (17:47 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 24 Aug 2021 17:31:35 +0000 (18:31 +0100)
Coverity CID: 1490048 Argument cannot be negative

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
jail/jail.c

index 24a3df3a38643b6e90735a3c39ca32820f9d791d..43a694aa1249bf6afad57372b1a05bd01192de1a 100644 (file)
@@ -395,6 +395,9 @@ static int create_dev_console(const char *jail_root)
 
        /* use PTY slave for stdio */
        slave_console_fd = open(console_fname, O_RDWR); /* | O_NOCTTY */
+       if (slave_console_fd < 0)
+               goto no_console;
+
        dup2(slave_console_fd, 0);
        dup2(slave_console_fd, 1);
        dup2(slave_console_fd, 2);