Skip to content

Commit 13b2027

Browse files
committed
stty: fix: reject "+hex" in parse_saved_state
1 parent 30fd234 commit 13b2027

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/uu/stty/src/stty.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,15 @@ fn parse_saved_state(arg: &str) -> Option<Vec<u32>> {
530530
// Validate all parts are non-empty valid hex
531531
let mut values = Vec::with_capacity(expected_parts);
532532
for (i, part) in parts.iter().enumerate() {
533+
// `from_str_radix` doesn't document its behavior for this case,
534+
// thus, we do this to guarantee stability
533535
if part.is_empty() {
534536
return None; // GNU rejects empty hex values
535537
}
538+
// TO-DO: avoid `from_str_radix`
539+
if part.as_bytes()[0] == b'+' {
540+
return None;
541+
}
536542
let val = u32::from_str_radix(part, 16).ok()?;
537543

538544
// Control characters (indices 4+) must fit in u8

0 commit comments

Comments
 (0)