Skip to content

Commit 6fde099

Browse files
committed
stty: fix: reject "+hex" in parse_saved_state
1 parent 2da2c90 commit 6fde099

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
@@ -510,9 +510,15 @@ fn parse_saved_state(arg: &str) -> Option<Vec<u32>> {
510510
// Validate all parts are non-empty valid hex
511511
let mut values = Vec::with_capacity(expected_parts);
512512
for (i, part) in parts.iter().enumerate() {
513+
// `from_str_radix` doesn't document its behavior for this case,
514+
// thus, we do this to guarantee stability
513515
if part.is_empty() {
514516
return None; // GNU rejects empty hex values
515517
}
518+
// TO-DO: avoid `from_str_radix`
519+
if part.as_bytes()[0] == b'+' {
520+
return None;
521+
}
516522
let val = u32::from_str_radix(part, 16).ok()?;
517523

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

0 commit comments

Comments
 (0)