From 6505d05803336300168d723a24e892ac7aee745f Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 12 Jul 2017 05:47:28 -0600 Subject: [PATCH] Clear input, output, control and local flags before copying them from the source terminal. Otherwise, flags that are disabled in the source terminal may still be enabled in the destination. --- lib/util/term.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/util/term.c b/lib/util/term.c index 0fb2eb205..d6fc8fee6 100644 --- a/lib/util/term.c +++ b/lib/util/term.c @@ -262,11 +262,17 @@ sudo_term_copy_v1(int src, int dst) if (tcgetattr(src, &tt_src) != 0 || tcgetattr(dst, &tt_dst) != 0) debug_return_bool(false); + /* Clear select input, output, control and local flags. */ + CLR(tt_dst.c_iflag, INPUT_FLAGS); + CLR(tt_dst.c_oflag, OUTPUT_FLAGS); + CLR(tt_dst.c_cflag, CONTROL_FLAGS); + CLR(tt_dst.c_lflag, LOCAL_FLAGS); + /* Copy select input, output, control and local flags. */ - tt_dst.c_iflag |= (tt_src.c_iflag & INPUT_FLAGS); - tt_dst.c_oflag |= (tt_src.c_oflag & OUTPUT_FLAGS); - tt_dst.c_cflag |= (tt_src.c_cflag & CONTROL_FLAGS); - tt_dst.c_lflag |= (tt_src.c_lflag & LOCAL_FLAGS); + SET(tt_dst.c_iflag, (tt_src.c_iflag & INPUT_FLAGS)); + SET(tt_dst.c_oflag, (tt_src.c_oflag & OUTPUT_FLAGS)); + SET(tt_dst.c_cflag, (tt_src.c_cflag & CONTROL_FLAGS)); + SET(tt_dst.c_lflag, (tt_src.c_lflag & LOCAL_FLAGS)); /* Copy special chars from src verbatim. */ for (i = 0; i < NCCS; i++) -- 2.40.0