stty bug in find_param

Sascha Hauer s.hauer at pengutronix.de
Thu Apr 19 15:32:51 UTC 2007


Hi,

The parameter 'cols' has the alias 'columns'. This introduces an
off-by-one error in paramter parsing. This one should fix it.

Sascha

---
 coreutils/stty.c |   22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

Index: busybox/coreutils/stty.c
===================================================================
--- busybox.orig/coreutils/stty.c
+++ busybox/coreutils/stty.c
@@ -550,13 +550,14 @@ static const struct control_info *find_c
 
 enum {
 	param_need_arg = 0x80,
-	param_line   = 1 | 0x80,
-	param_rows   = 2 | 0x80,
-	param_cols   = 3 | 0x80,
-	param_size   = 4,
-	param_speed  = 5,
-	param_ispeed = 6 | 0x80,
-	param_ospeed = 7 | 0x80,
+	param_line    = 1 | 0x80,
+	param_rows    = 2 | 0x80,
+	param_cols    = 3 | 0x80,
+	param_columns = 4 | 0x80,
+	param_size    = 5,
+	param_speed   = 6,
+	param_ispeed  = 7 | 0x80,
+	param_ospeed  = 8 | 0x80,
 };
 
 static int find_param(const char * const name)
@@ -566,8 +567,8 @@ static int find_param(const char * const
 		"rows",
 		"cols",
 		"columns",
-		"size",  /* 4 */
-		"speed", /* 5 */
+		"size",  /* 5 */
+		"speed", /* 6 */
 		"ispeed",
 		"ospeed",
 		NULL
@@ -575,7 +576,7 @@ static int find_param(const char * const
 	int i = index_in_str_array(params, name) + 1;
 	if (i == 0)
 		return 0;
-	if (!(i == 4 || i == 5))
+	if (!(i == 5 || i == 6))
 		i |= 0x80;
 
 	return i;
@@ -1014,6 +1015,7 @@ int stty_main(int argc, char **argv)
 #ifdef TIOCGWINSZ
 		case param_rows:
 		case param_cols:
+		case param_columns:
 			xatoul_range_sfx(argnext, 1, INT_MAX, stty_suffixes);
 			break;
 		case param_size:




More information about the busybox mailing list