ujail-console: add missing error handling discovered by coverity
authorDaniel Golle <daniel@makrotopia.org>
Fri, 13 Aug 2021 18:14:12 +0000 (19:14 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Sat, 14 Aug 2021 17:58:45 +0000 (18:58 +0100)
Coverity CID: 1490106
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
jail/console.c

index 588d24114bc499117a720b9be48161f2328e4cbe..498756fc60aa47bf992ffc54d957cd9f456dbaae 100644 (file)
@@ -163,9 +163,16 @@ int main(int argc, char **argv)
                ubus_free(ctx);
                return -1;
        }
-
        setup_tios(server_fd, &oldtermios);
+
        tty_fd = open("/dev/tty", O_RDWR);
+       if (tty_fd < 0) {
+               fprintf(stderr, "can't open local console!\n");
+               close(server_fd);
+               close(client_fd);
+               ubus_free(ctx);
+               return -1;
+       }
        setup_tios(tty_fd, &oldtermios);
 
        /* register server-side with procd */