]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: check fcntl() return value [coverity: CID 503788]
authorKarel Zak <kzak@redhat.com>
Mon, 13 Jul 2026 10:07:25 +0000 (12:07 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 13 Jul 2026 10:07:25 +0000 (12:07 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
agetty-cmd/tty.c

index e56e5f1bbbd9b82ef2763d3f45f069dfb9f1fd59..38a963658921bc163614b949d37a0eb924e10245 100644 (file)
@@ -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)