From 66a03cfbfb3172cad09f7dfc56998a9cca897ab4 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 23 Oct 2026 17:04:19 +0300 Subject: [PATCH] config: Fix panic on a bind key with a null byte keysym_from_name() calls CString::new(key).unwrap(). --- niri-config/src/binds.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) 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::(); + } }