From 9c0a3a27f70bbb27e839404571922b0f8f0d48da Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Mon, 9 Jan 2017 00:07:42 +0000 Subject: 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. --- tests/misc/stty.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/misc/stty.sh') 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 -- cgit v1.2.3-70-g09d2