summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2016-03-29 13:53:28 +0200
committerKarel Zak <kzak@redhat.com>2016-03-29 13:57:13 +0200
commitcf5828599afe169f928e0a738ebee19f90384b20 (patch)
tree04ba50e5a18a74c8588d42761507b95ae7ad0c9d
parent76839e9794e2841bce6a6c3a5a91e02f4918e646 (diff)
downloadutil-linux-cf5828599afe169f928e0a738ebee19f90384b20.tar.gz
agetty: remove atoi() from argv[] parsing [clang analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--term-utils/agetty.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 1df1bc861..6d610c608 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -152,7 +152,7 @@ static int netlink_fd = AGETTY_RELOAD_FDNONE;
struct options {
int flags; /* toggle switches, see below */
- int timeout; /* time-out period */
+ unsigned int timeout; /* time-out period */
char *autolog; /* login the user automatically */
char *chdir; /* Chdir before the login */
char *chroot; /* Chroot before the login */
@@ -166,7 +166,7 @@ struct options {
char *erasechars; /* string with erase chars */
char *killchars; /* string with kill chars */
char *osrelease; /* /etc/os-release data */
- int delay; /* Sleep seconds before prompt */
+ unsigned int delay; /* Sleep seconds before prompt */
int nice; /* Run login with this priority */
int numspeed; /* number of baud rates to try */
int clocal; /* CLOCAL_MODE_* */
@@ -421,7 +421,7 @@ int main(int argc, char **argv)
/* Set the optional timer. */
if (options.timeout)
- alarm((unsigned) options.timeout);
+ alarm(options.timeout);
/* Optionally wait for CR or LF before writing /etc/issue */
if (serial_tty_option(&options, F_WAITCRLF)) {
@@ -681,7 +681,7 @@ static void parse_args(int argc, char **argv, struct options *op)
op->chdir = optarg;
break;
case 'd':
- op->delay = atoi(optarg);
+ op->delay = strtou32_or_err(optarg, _("invalid delay argument"));
break;
case 'E':
op->flags |= F_REMOTE;
@@ -739,7 +739,7 @@ static void parse_args(int argc, char **argv, struct options *op)
op->flags |= F_LOGINPAUSE;
break;
case 'P':
- op->nice = atoi(optarg);
+ op->nice = strtos32_or_err(optarg, _("invalid nice argument"));
break;
case 'r':
op->chroot = optarg;
@@ -751,8 +751,7 @@ static void parse_args(int argc, char **argv, struct options *op)
op->flags |= F_KEEPSPEED;
break;
case 't':
- if ((op->timeout = atoi(optarg)) <= 0)
- log_err(_("bad timeout value: %s"), optarg);
+ op->timeout = strtou32_or_err(optarg, _("invalid timeout argument"));
break;
case 'U':
op->flags |= F_LCUC;