From: Todd C. Miller Date: Wed, 12 Jul 2017 11:47:28 +0000 (-0600) Subject: Clear input, output, control and local flags before copying them X-Git-Tag: SUDO_1_8_21^2~44 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6505d05803336300168d723a24e892ac7aee745f;p=sudo 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. --- 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++)