Skip to content

fix(macos): handle device names containing embedded NULs - #2132

Open
malpern wants to merge 1 commit into
jtroo:mainfrom
malpern:agent/macos-device-name-nul
Open

fix(macos): handle device names containing embedded NULs#2132
malpern wants to merge 1 commit into
jtroo:mainfrom
malpern:agent/macos-device-name-nul

Conversation

@malpern

@malpern malpern commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Truncate macOS HID device names at the first embedded NUL before calling device_matches or register_device.
  • Use the existing hash fallback, or skip the entry, when the usable name is empty.
  • Add regression coverage for valid names, embedded NULs, empty prefixes, and preserving U+FFFD.

Why

karabiner-driverkit converts these names with CString::new(...).expect(...). An embedded NUL therefore panics instead of being handled as a malformed device name, which aborts Kanata and stops remapping. I originally encountered this downstream in malpern/KeyPath#631.

The change is limited to the macOS device-name paths that cross this C string boundary; ordinary names retain their existing matching behavior.

Validation

  • cargo fmt --all --check
  • cargo test device_name_tests
  • cargo test --all
  • cargo clippy --all -- -D warnings
  • cargo test --all --features=cmd
  • cargo clippy --all --features=cmd -- -D warnings

@malpern
malpern marked this pull request as ready for review August 4, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant