Skip to content

stty: clear grouped flags before setting a new value - #15434

Open
limadog9 wants to merge 1 commit into
uutils:mainfrom
limadog9:fix/stty-grouped-flags
Open

limadog9 wants to merge 1 commit into
uutils:mainfrom
limadog9:fix/stty-grouped-flags

Conversation

@limadog9

Copy link
Copy Markdown
Contributor

Clear a grouped setting’s mask before applying its selected value. Character sizes (cs5–cs8) and output delay settings now replace the previous value while preserving unrelated flags.

Closes #11963

Comment thread src/uu/stty/src/stty.rs Outdated
}
}

termios.control_flags = ControlFlags::CS7 | other_flags;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the parenb part needed? it isn't about grouped flags, i would drop it

}
}

#[cfg(target_os = "linux")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please also add the reported case here (cs8 then cs7)? the CSIZE group is only covered by the unit test

@limadog9
limadog9 force-pushed the fix/stty-grouped-flags branch from d967c12 to 29df738 Compare October 17, 2026 12:49
@limadog9

Copy link
Copy Markdown
Contributor Author

Removed the unrelated parity assertions and added a real-binary regression test for CS8 → CS7. It catches the original bug, and all 85 active tests and Clippy pass. Squashed the update into one commit.

.no_output();

// Linux PTYs reject CS7. Leaving CS8 set would incorrectly succeed.
new_ucmd!()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this relies on the kernel rejecting cs7 on a pty, isn't it fragile with other kernel versions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch—removed the assumption that CS7 must fail. The test now compares stty’s result and resulting flags with a direct tcsetattr call on the same PTY, allowing for platform differences.

@limadog9
limadog9 force-pushed the fix/stty-grouped-flags branch from 29df738 to 6bc2628 Compare October 17, 2026 14:11
Comment thread tests/by-util/test_stty.rs Outdated
#[cfg(target_os = "linux")]
#[test]
fn test_character_size_cs8_then_cs7() {
use nix::sys::termios::{ControlFlags, SetArg, tcgetattr, tcsetattr};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you use rustix instead of nix at test_stty.rs?

@limadog9
limadog9 force-pushed the fix/stty-grouped-flags branch from 6bc2628 to 0733938 Compare October 21, 2026 19:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stty: setting a grouped control flag (e.g. cs7) does not clear existing group bits first

3 participants