aboutsummaryrefslogtreecommitdiff
path: root/loginutils/getty.c
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-10-08 12:49:22 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-10-08 12:49:22 +0000
commit87d25a2b8535dc627a02eb539fa3946be2a24647 (patch)
treefc4d14a910593d1235318bb36abe5e9f72d2039e /loginutils/getty.c
parent81177b14907e73f11560f69e0b4ec34371f1a7d5 (diff)
downloadbusybox-w32-87d25a2b8535dc627a02eb539fa3946be2a24647.tar.gz
busybox-w32-87d25a2b8535dc627a02eb539fa3946be2a24647.tar.bz2
busybox-w32-87d25a2b8535dc627a02eb539fa3946be2a24647.zip
attempt to regularize atoi mess.
git-svn-id: svn://busybox.net/trunk/busybox@16342 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'loginutils/getty.c')
-rw-r--r--loginutils/getty.c17
1 files changed, 9 insertions, 8 deletions
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
114struct options { 114struct 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;
226static int bcode(const char *s) 226static 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) {