2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 14:25:15 +00:00

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.
This commit is contained in:
Todd C. Miller
2017-07-12 05:47:28 -06:00
parent e70a953fb4
commit 6505d05803

View File

@@ -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++)