diff options
author | Pádraig Brady <P@draigBrady.com> | 2017-01-09 00:07:42 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2017-01-09 00:27:07 +0000 |
commit | 9c0a3a27f70bbb27e839404571922b0f8f0d48da (patch) | |
tree | 4d2d6c9857321db2a9b45b23c9485bd555cccc13 /tests/misc/stty.sh | |
parent | 229431d63caf2dcb411da565a9fc7e51fa2ac809 (diff) | |
download | coreutils-9c0a3a27f70bbb27e839404571922b0f8f0d48da.tar.xz |
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.
Diffstat (limited to 'tests/misc/stty.sh')
-rwxr-xr-x | tests/misc/stty.sh | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/misc/stty.sh b/tests/misc/stty.sh index f6200e715..e549adb65 100755 --- a/tests/misc/stty.sh +++ b/tests/misc/stty.sh @@ -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 |