From: Daniel Golle Date: Fri, 13 Aug 2021 18:14:12 +0000 (+0100) Subject: ujail-console: add missing error handling discovered by coverity X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=2562e2b38d14fb1f337202feb6376fd447f30222;p=project%2Fprocd.git ujail-console: add missing error handling discovered by coverity Coverity CID: 1490106 Signed-off-by: Daniel Golle --- diff --git a/jail/console.c b/jail/console.c index 588d241..498756f 100644 --- a/jail/console.c +++ b/jail/console.c @@ -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 */