diff --git a/man/man1/stty.1 b/man/man1/stty.1 index 1792c26..11caf3c 100644 --- a/man/man1/stty.1 +++ b/man/man1/stty.1 @@ -112,8 +112,8 @@ The settings .BR cols , and .BR columns , -which resize the window on Unix, are recognized but always fail: -a number after one of them is reported as an invalid argument. +which resize the window on Unix, are not supported and are rejected as +invalid arguments. .SH OPTIONS .TP .B \-a @@ -235,14 +235,13 @@ There is no way to save the current mode and restore it later, because .B \-g is not supported. .PP -When +busybox-w32 recognizes .BR rows , .BR cols , -or -.B columns -is the last argument, with no number after it, -.B stty -crashes instead of reporting an error. +and +.BR columns , +but rejects the number after them, and crashes when nothing follows. +w64devkit rejects them outright. .PP .BR ttysize (1) also prints the console size, prints the width first by default, and diff --git a/src/busybox/series b/src/busybox/series index 0478c0a..9bff76f 100644 --- a/src/busybox/series +++ b/src/busybox/series @@ -11,3 +11,4 @@ less-raw-sgr.patch bare-drive.patch rm-bare-drive.patch drop-test2.patch +stty-winsize.patch diff --git a/src/busybox/stty-winsize.patch b/src/busybox/stty-winsize.patch new file mode 100644 index 0000000..2f3001e --- /dev/null +++ b/src/busybox/stty-winsize.patch @@ -0,0 +1,33 @@ +On Windows, stty recognized rows, cols and columns as settings, though +it cannot set the window size and its usage lists only size. The first +pass checked the following number without consuming it, so "stty rows +30" always failed with "invalid argument '30'", and "stty rows" with +nothing after it dereferenced a null pointer and crashed. Recognize only +size, so these are rejected as invalid arguments like other settings +the Windows build lacks. + +--- a/coreutils/stty.c ++++ b/coreutils/stty.c +@@ -1008,17 +1008,11 @@ + + static int find_param(const char *name) + { +- static const char params[] ALIGN1 = +- "rows\0" /* 1 */ +- "cols\0" /* 2 */ +- "columns\0" /* 3 */ +- "size\0"; /* 4 */ +- int i = index_in_strings(params, name) + 1; +- if (i == 0) +- return 0; +- if (i != 4) +- i |= 0x80; +- return i; ++ /* The window size cannot be set, so rows, cols and columns are ++ * not settings: accepting them consumed no argument, and with ++ * none following, dereferenced a null pointer. ++ */ ++ return strcmp(name, "size") == 0 ? param_size : 0; + } + #endif +