summaryrefslogtreecommitdiffstats
path: root/term-utils/agetty.c
diff options
context:
space:
mode:
authorYuriy M. Kaminskiy2016-02-27 17:27:29 +0100
committerKarel Zak2016-03-07 15:11:06 +0100
commit06fa5817489adb9728f8a29d4cb7602fb48b8bdb (patch)
treeb3a6f1d0db6b1a6d0e340c1297f243c07c1de618 /term-utils/agetty.c
parentlsns.c: fix error return (diff)
downloadkernel-qcow2-util-linux-06fa5817489adb9728f8a29d4cb7602fb48b8bdb.tar.gz
kernel-qcow2-util-linux-06fa5817489adb9728f8a29d4cb7602fb48b8bdb.tar.xz
kernel-qcow2-util-linux-06fa5817489adb9728f8a29d4cb7602fb48b8bdb.zip
misc: safer (and uniform) handling of return value
When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils/agetty.c')
-rw-r--r--term-utils/agetty.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index d88cdc1c0..55a00e125 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -1001,8 +1001,8 @@ static void open_tty(char *tty, struct termios *tp, struct options *op)
if ((gr = getgrnam("tty")))
gid = gr->gr_gid;
- if (((len = snprintf(buf, sizeof(buf), "/dev/%s", tty)) >=
- (int)sizeof(buf)) || (len < 0))
+ len = snprintf(buf, sizeof(buf), "/dev/%s", tty);
+ if (len < 0 || (size_t)len >= sizeof(buf))
log_err(_("/dev/%s: cannot open as standard input: %m"), tty);
/* Open the tty as standard input. */