Skip to content

Commit a59d227

Browse files
committed
stty: fix: reject "+hex" in parse_saved_state
1 parent d41ed38 commit a59d227

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
@@ -524,9 +524,15 @@ fn parse_saved_state(arg: &str) -> Option<Vec<u32>> {
524524
// Validate all parts are non-empty valid hex
525525
let mut values = Vec::with_capacity(expected_parts);
526526
for (i, part) in parts.iter().enumerate() {
527+
// `from_str_radix` doesn't document its behavior for this case,
528+
// thus, we do this to guarantee stability
527529
if part.is_empty() {
528530
return None; // GNU rejects empty hex values
529531
}
532+
// TO-DO: avoid `from_str_radix`
533+
if part.as_bytes()[0] == b'+' {
534+
return None;
535+
}
530536
let val = u32::from_str_radix(part, 16).ok()?;
531537

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

0 commit comments

Comments
 (0)