mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-04-21 11:16:16 +02:00
stty: ensure no side effects from invalid options
* src/stty.c (apply_settings): A new function refactored from main() that is used to both check and apply options. (main): Call apply_settings before we open the device, so all validation is done before interacting with a device. * NEWS: Mention the improvement. * tests/misc/stty.sh: Add a test case.
This commit is contained in:
@@ -22,6 +22,7 @@ print_ver_ stty
|
||||
|
||||
require_controlling_input_terminal_
|
||||
require_trap_signame_
|
||||
require_strace_ ioctl
|
||||
|
||||
trap '' TTOU # Ignore SIGTTOU
|
||||
|
||||
@@ -81,4 +82,11 @@ done
|
||||
|
||||
stty $(cat $saved_state)
|
||||
|
||||
# Ensure we validate options before accessing the device
|
||||
strace -o log1 -e ioctl stty --version || fail=1
|
||||
n_ioctl1=$(wc -l < log1) || framework_failure_
|
||||
returns_ 1 strace -o log2 -e ioctl stty -blahblah || fail=1
|
||||
n_ioctl2=$(wc -l < log2) || framework_failure_
|
||||
test "$n_ioctl1" = "$n_ioctl2" || fail=1
|
||||
|
||||
Exit $fail
|
||||
|
||||
Reference in New Issue
Block a user