1
0
mirror of https://git.savannah.gnu.org/git/coreutils.git synced 2026-10-24 02:08:57 +03:00

stty: fix incorrectly accepting empty speeds

* src/stty.c (string_to_baud): Disallow empty speeds.
* tests/stty/stty-invalid.sh: Add checks.
* NEWS: Mention the bug fix.

Link: https://github.com/coreutils/coreutils/issues/380
This commit is contained in:
Pádraig Brady
2026-10-14 14:35:30 +01:00
parent 8b16b32356
commit 292bd77de7
3 changed files with 9 additions and 1 deletions

4
NEWS
View File

@@ -28,6 +28,10 @@ GNU coreutils NEWS -*- outline -*-
resolves to a path beginning with the symbolic link itself.
[bug introduced in coreutils-9.0]
'stty' again rejects empty speed arguments.
Previously such arguments were accepted as value 0.
[bug introduced in coreutils-9.8]
'unexpand' no longer overflows a heap buffer on non-GLIBC platforms,
given whitespace characters whose display width is negative. E.g.,
this edge case can occur with \u0085 (next line) characters on musl.

View File

@@ -2265,6 +2265,10 @@ string_to_baud (char const *arg)
if (*arg == '-')
return (speed_t) -1;
/* Empty does not mean 0. */
if (! *arg)
return (speed_t) -1;
value = strtoul (arg, &ep, 10);
c = *ep++;

View File

@@ -56,7 +56,7 @@ fi
# We simulate unsupported numbers in a separate "LD_PRELOAD" test.
WRAP_9600="$(expr $ULONG_OFLOW - 9600)"
for speed in 9599.. 9600.. 9600.5. 9600.50. 9600.0. ++9600 \
-$WRAP_9600 --$WRAP_9600 0x2580 96E2 9600,0 '9600.0 '; do
-$WRAP_9600 --$WRAP_9600 0x2580 96E2 9600,0 '9600.0 ' '' ' '; do
returns_ 1 stty ispeed "$speed" || fail=1
done