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:
4
NEWS
4
NEWS
@@ -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.
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user