aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorEthan Sommer <e5ten.arch@gmail.com>2020-04-27 16:50:56 -0400
committerRob Landley <rob@landley.net>2020-05-08 15:28:45 -0500
commit9c72f3136e9f5840a429a839da1313554bcc6c81 (patch)
tree7e31ee8c9ca9585677c2c34c528eab20253b04c7 /toys
parent4761d756dde03e62de0c3f3d7f25067a4f207fa3 (diff)
downloadtoybox-9c72f3136e9f5840a429a839da1313554bcc6c81.tar.gz
stty.c: fix interpreting output of stty -g
move case checking for stty -g output as input above case checking for an int argument, so atoi doesn't cause "500:5:bf:8a3b:3"... to be considered an int argument of 500
Diffstat (limited to 'toys')
-rw-r--r--toys/pending/stty.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/toys/pending/stty.c b/toys/pending/stty.c
index df12526b..4ab6b805 100644
--- a/toys/pending/stty.c
+++ b/toys/pending/stty.c
@@ -332,18 +332,6 @@ static void do_stty()
else if (!strcmp(arg, "line")) new.c_line = get_arg(&i, N_TTY, NR_LDISCS);
else if (!strcmp(arg, "min")) new.c_cc[VMIN] = get_arg(&i, 0, 255);
else if (!strcmp(arg, "time")) new.c_cc[VTIME] = get_arg(&i, 0, 255);
- else if (atoi(arg) > 0) {
- int new_speed = speed(atolx_range(arg, 0, 4000000));
-
- cfsetispeed(&new, new_speed);
- cfsetospeed(&new, new_speed);
- } else if (!strcmp(arg, "ispeed"))
- cfsetispeed(&new, speed(get_arg(&i, 0, 4000000)));
- else if (!strcmp(arg, "ospeed"))
- cfsetospeed(&new, speed(get_arg(&i, 0, 4000000)));
- else if (!strcmp(arg, "rows")) set_size(1, get_arg(&i, 0, USHRT_MAX));
- else if (!strcmp(arg, "cols") || !strcmp(arg, "columns"))
- set_size(0, get_arg(&i, 0, USHRT_MAX));
else if (sscanf(arg, "%x:%x:%x:%x:%n", &new.c_iflag, &new.c_oflag,
&new.c_cflag, &new.c_lflag, &n) == 4)
{
@@ -355,7 +343,19 @@ static void do_stty()
new.c_cc[j] = value;
arg += n+1;
}
- } else if (set_special_character(&new, &i, arg));
+ } else if (atoi(arg) > 0) {
+ int new_speed = speed(atolx_range(arg, 0, 4000000));
+
+ cfsetispeed(&new, new_speed);
+ cfsetospeed(&new, new_speed);
+ } else if (!strcmp(arg, "ispeed"))
+ cfsetispeed(&new, speed(get_arg(&i, 0, 4000000)));
+ else if (!strcmp(arg, "ospeed"))
+ cfsetospeed(&new, speed(get_arg(&i, 0, 4000000)));
+ else if (!strcmp(arg, "rows")) set_size(1, get_arg(&i, 0, USHRT_MAX));
+ else if (!strcmp(arg, "cols") || !strcmp(arg, "columns"))
+ set_size(0, get_arg(&i, 0, USHRT_MAX));
+ else if (set_special_character(&new, &i, arg));
// Already done as a side effect.
else if (!strcmp(arg, "cooked"))
set_options(&new, "brkint", "ignpar", "istrip", "icrnl", "ixon",