diff --git a/niri-config/src/binds.rs b/niri-config/src/binds.rs index 2266d877..27eeee3e 100644 --- a/niri-config/src/binds.rs +++ b/niri-config/src/binds.rs @@ -953,6 +953,10 @@ impl FromStr for Key { type Err = miette::Error; fn from_str(s: &str) -> Result { + if s.contains('\0') { + return Err(miette!("invalid key with a null byte: {s:?}")); + } + let mut modifiers = Modifiers::empty(); let mut split = s.split('+'); @@ -1115,4 +1119,10 @@ mod tests { }, ); } + + #[test] + fn null_byte() { + // Shouldn't panic. + let _ = "W\0".parse::(); + } }