aboutsummaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-08 12:49:22 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-08 12:49:22 +0000
commit1385899416a4396385ad421ae1f532be7103738a (patch)
treefc4d14a910593d1235318bb36abe5e9f72d2039e /loginutils
parent5625415085e68ac5e150f54e685417c866620d76 (diff)
downloadbusybox-1385899416a4396385ad421ae1f532be7103738a.tar.gz
attempt to regularize atoi mess.
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/addgroup.c5
-rw-r--r--loginutils/getty.c17
-rw-r--r--loginutils/sulogin.c6
-rw-r--r--loginutils/vlock.c2
4 files changed, 14 insertions, 16 deletions
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index 236dc1099..0172e6041 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -91,15 +91,14 @@ int addgroup_main(int argc, char **argv)
/* check for min, max and missing args and exit on error */
opt_complementary = "-1:?2:?";
-
if (getopt32(argc, argv, "g:", &group)) {
- gid = bb_xgetlarg(group, 10, 0, LONG_MAX);
+ gid = xatoul_range(group, 0, (gid_t)ULONG_MAX);
}
/* move past the commandline options */
argv += optind;
/* need to be root */
- if(geteuid()) {
+ if (geteuid()) {
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
}
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 4b43684a2..d279dc3a4 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -113,7 +113,7 @@ extern void updwtmp(const char *filename, const struct utmp *ut);
struct options {
int flags; /* toggle switches, see below */
- int timeout; /* time-out period */
+ unsigned timeout; /* time-out period */
char *login; /* login program */
char *tty; /* name of tty */
char *initstring; /* modem init string */
@@ -226,11 +226,12 @@ FILE *dbf;
static int bcode(const char *s)
{
int r;
- unsigned long value;
- if (safe_strtoul((char *)s, &value)) {
+ unsigned value;
+ if (safe_strtou((char *)s, &value)) {
return -1;
}
- if ((r = tty_value_to_baud(value)) > 0) {
+ r = tty_value_to_baud(value);
+ if (r > 0) {
return r;
}
return 0;
@@ -280,8 +281,7 @@ static void parse_args(int argc, char **argv, struct options *op)
}
op->flags ^= F_ISSUE; /* revert flag show /etc/issue */
if(op->flags & F_TIMEOUT) {
- if ((op->timeout = atoi(ts)) <= 0)
- bb_error_msg_and_die("bad timeout value: %s", ts);
+ op->timeout = xatoul_range(ts, 1, INT_MAX);
}
debug("after getopt loop\n");
if (argc < optind + 2) /* check parameter count */
@@ -495,7 +495,8 @@ static void auto_baud(struct termio *tp)
buf[nread] = '\0';
for (bp = buf; bp < buf + nread; bp++) {
if (isascii(*bp) && isdigit(*bp)) {
- if ((speed = bcode(bp))) {
+ speed = bcode(bp);
+ if (speed) {
tp->c_cflag &= ~CBAUD;
tp->c_cflag |= speed;
}
@@ -881,7 +882,7 @@ int getty_main(int argc, char **argv)
/* Set the optional timer. */
if (options.timeout)
- (void) alarm((unsigned) options.timeout);
+ (void) alarm(options.timeout);
/* optionally wait for CR or LF before writing /etc/issue */
if (options.flags & F_WAITCRLF) {
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index 40eb5e9cf..679439544 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -46,10 +46,8 @@ int sulogin_main(int argc, char **argv)
logmode = LOGMODE_BOTH;
openlog(applet_name, 0, LOG_AUTH);
- if (getopt32 (argc, argv, "t:", &timeout_arg)) {
- if (safe_strtoi(timeout_arg, &timeout)) {
- timeout = 0;
- }
+ if (getopt32(argc, argv, "t:", &timeout_arg)) {
+ timeout = xatoi_u(timeout_arg);
}
if (argv[optind]) {
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index 02d1ea772..9ab097b77 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -55,7 +55,7 @@ int vlock_main(int argc, char **argv)
bb_show_usage();
}
- o_lock_all = getopt32 (argc, argv, "a");
+ o_lock_all = getopt32(argc, argv, "a");
if((pw = getpwuid(getuid())) == NULL) {
bb_error_msg_and_die("Unknown uid %d", getuid());