From: Daniel Golle Date: Mon, 23 Aug 2021 16:47:23 +0000 (+0100) Subject: jail: check return value when opening console X-Git-Url: http://git.openwrt.org/openwrt/svn-archive.git?a=commitdiff_plain;h=3edb7ebecb266db545fe2e79ef552a9b09beaa6f;p=project%2Fprocd.git jail: check return value when opening console Coverity CID: 1490048 Argument cannot be negative Signed-off-by: Daniel Golle --- diff --git a/jail/jail.c b/jail/jail.c index 24a3df3..43a694a 100644 --- a/jail/jail.c +++ b/jail/jail.c @@ -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);