diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-08 12:49:22 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-08 12:49:22 +0000 |
commit | 1385899416a4396385ad421ae1f532be7103738a (patch) | |
tree | fc4d14a910593d1235318bb36abe5e9f72d2039e /loginutils | |
parent | 5625415085e68ac5e150f54e685417c866620d76 (diff) | |
download | busybox-w32-1385899416a4396385ad421ae1f532be7103738a.tar.gz busybox-w32-1385899416a4396385ad421ae1f532be7103738a.tar.bz2 busybox-w32-1385899416a4396385ad421ae1f532be7103738a.zip |
attempt to regularize atoi mess.
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/addgroup.c | 5 | ||||
-rw-r--r-- | loginutils/getty.c | 17 | ||||
-rw-r--r-- | loginutils/sulogin.c | 6 | ||||
-rw-r--r-- | loginutils/vlock.c | 2 |
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) | |||
91 | 91 | ||
92 | /* check for min, max and missing args and exit on error */ | 92 | /* check for min, max and missing args and exit on error */ |
93 | opt_complementary = "-1:?2:?"; | 93 | opt_complementary = "-1:?2:?"; |
94 | |||
95 | if (getopt32(argc, argv, "g:", &group)) { | 94 | if (getopt32(argc, argv, "g:", &group)) { |
96 | gid = bb_xgetlarg(group, 10, 0, LONG_MAX); | 95 | gid = xatoul_range(group, 0, (gid_t)ULONG_MAX); |
97 | } | 96 | } |
98 | /* move past the commandline options */ | 97 | /* move past the commandline options */ |
99 | argv += optind; | 98 | argv += optind; |
100 | 99 | ||
101 | /* need to be root */ | 100 | /* need to be root */ |
102 | if(geteuid()) { | 101 | if (geteuid()) { |
103 | bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); | 102 | bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); |
104 | } | 103 | } |
105 | 104 | ||
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); | |||
113 | 113 | ||
114 | struct options { | 114 | struct options { |
115 | int flags; /* toggle switches, see below */ | 115 | int flags; /* toggle switches, see below */ |
116 | int timeout; /* time-out period */ | 116 | unsigned timeout; /* time-out period */ |
117 | char *login; /* login program */ | 117 | char *login; /* login program */ |
118 | char *tty; /* name of tty */ | 118 | char *tty; /* name of tty */ |
119 | char *initstring; /* modem init string */ | 119 | char *initstring; /* modem init string */ |
@@ -226,11 +226,12 @@ FILE *dbf; | |||
226 | static int bcode(const char *s) | 226 | static int bcode(const char *s) |
227 | { | 227 | { |
228 | int r; | 228 | int r; |
229 | unsigned long value; | 229 | unsigned value; |
230 | if (safe_strtoul((char *)s, &value)) { | 230 | if (safe_strtou((char *)s, &value)) { |
231 | return -1; | 231 | return -1; |
232 | } | 232 | } |
233 | if ((r = tty_value_to_baud(value)) > 0) { | 233 | r = tty_value_to_baud(value); |
234 | if (r > 0) { | ||
234 | return r; | 235 | return r; |
235 | } | 236 | } |
236 | return 0; | 237 | return 0; |
@@ -280,8 +281,7 @@ static void parse_args(int argc, char **argv, struct options *op) | |||
280 | } | 281 | } |
281 | op->flags ^= F_ISSUE; /* revert flag show /etc/issue */ | 282 | op->flags ^= F_ISSUE; /* revert flag show /etc/issue */ |
282 | if(op->flags & F_TIMEOUT) { | 283 | if(op->flags & F_TIMEOUT) { |
283 | if ((op->timeout = atoi(ts)) <= 0) | 284 | op->timeout = xatoul_range(ts, 1, INT_MAX); |
284 | bb_error_msg_and_die("bad timeout value: %s", ts); | ||
285 | } | 285 | } |
286 | debug("after getopt loop\n"); | 286 | debug("after getopt loop\n"); |
287 | if (argc < optind + 2) /* check parameter count */ | 287 | if (argc < optind + 2) /* check parameter count */ |
@@ -495,7 +495,8 @@ static void auto_baud(struct termio *tp) | |||
495 | buf[nread] = '\0'; | 495 | buf[nread] = '\0'; |
496 | for (bp = buf; bp < buf + nread; bp++) { | 496 | for (bp = buf; bp < buf + nread; bp++) { |
497 | if (isascii(*bp) && isdigit(*bp)) { | 497 | if (isascii(*bp) && isdigit(*bp)) { |
498 | if ((speed = bcode(bp))) { | 498 | speed = bcode(bp); |
499 | if (speed) { | ||
499 | tp->c_cflag &= ~CBAUD; | 500 | tp->c_cflag &= ~CBAUD; |
500 | tp->c_cflag |= speed; | 501 | tp->c_cflag |= speed; |
501 | } | 502 | } |
@@ -881,7 +882,7 @@ int getty_main(int argc, char **argv) | |||
881 | 882 | ||
882 | /* Set the optional timer. */ | 883 | /* Set the optional timer. */ |
883 | if (options.timeout) | 884 | if (options.timeout) |
884 | (void) alarm((unsigned) options.timeout); | 885 | (void) alarm(options.timeout); |
885 | 886 | ||
886 | /* optionally wait for CR or LF before writing /etc/issue */ | 887 | /* optionally wait for CR or LF before writing /etc/issue */ |
887 | if (options.flags & F_WAITCRLF) { | 888 | 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) | |||
46 | logmode = LOGMODE_BOTH; | 46 | logmode = LOGMODE_BOTH; |
47 | openlog(applet_name, 0, LOG_AUTH); | 47 | openlog(applet_name, 0, LOG_AUTH); |
48 | 48 | ||
49 | if (getopt32 (argc, argv, "t:", &timeout_arg)) { | 49 | if (getopt32(argc, argv, "t:", &timeout_arg)) { |
50 | if (safe_strtoi(timeout_arg, &timeout)) { | 50 | timeout = xatoi_u(timeout_arg); |
51 | timeout = 0; | ||
52 | } | ||
53 | } | 51 | } |
54 | 52 | ||
55 | if (argv[optind]) { | 53 | 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) | |||
55 | bb_show_usage(); | 55 | bb_show_usage(); |
56 | } | 56 | } |
57 | 57 | ||
58 | o_lock_all = getopt32 (argc, argv, "a"); | 58 | o_lock_all = getopt32(argc, argv, "a"); |
59 | 59 | ||
60 | if((pw = getpwuid(getuid())) == NULL) { | 60 | if((pw = getpwuid(getuid())) == NULL) { |
61 | bb_error_msg_and_die("Unknown uid %d", getuid()); | 61 | bb_error_msg_and_die("Unknown uid %d", getuid()); |