From: Karel Zak Date: Mon, 13 Jul 2026 10:07:25 +0000 (+0200) Subject: agetty: check fcntl() return value [coverity: CID 503788] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c93fa6fdc0d13029170a60a84609dceb71eb338;p=thirdparty%2Futil-linux.git agetty: check fcntl() return value [coverity: CID 503788] Signed-off-by: Karel Zak --- diff --git a/agetty-cmd/tty.c b/agetty-cmd/tty.c index e56e5f1bb..38a963658 100644 --- a/agetty-cmd/tty.c +++ b/agetty-cmd/tty.c @@ -193,8 +193,9 @@ void agetty_reset_vc(const struct agetty_options *op, struct termios *tp, int ca agetty_log_warn(_("setting terminal attributes failed: %m")); /* Go to blocking input even in local mode. */ - fcntl(STDIN_FILENO, F_SETFL, - fcntl(STDIN_FILENO, F_GETFL, 0) & ~O_NONBLOCK); + fl = fcntl(STDIN_FILENO, F_GETFL, 0); + if (fl >= 0) + fcntl(STDIN_FILENO, F_SETFL, fl & ~O_NONBLOCK); } void agetty_open_tty(const char *tty, struct termios *tp, struct agetty_options *op)