Skip to content

fix(dpi): drop trailing NULs from the DHCP host name - #760

Merged
domcyrus merged 1 commit into
domcyrus:mainfrom
JROtto5:fix/dhcp-hostname-trailing-nul
Nov 28, 2026
Merged

domcyrus merged 1 commit into
domcyrus:mainfrom
JROtto5:fix/dhcp-hostname-trailing-nul

Conversation

@JROtto5

@JROtto5 JROtto5 commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Windows DHCP clients end the host name option (12) with a NUL byte, so RustNet shows DESKTOP-ABC\0 as the hostname in the connection label, Details, JSON output and filter matching, where an anchored regex such as ^desktop-abc$ misses it. RFC 2132 section 2 says receivers must be prepared to delete trailing NULs in these options, and dnsmasq handles the same quirk for Microsoft clients. The parser now drops trailing NULs before decoding the name.

Verification

Run on Linux (x86_64). This machine has no libpcap or libelf headers, so the crates that link pcap and the ebpf feature were not built. None of them changed.

  • cargo fmt --all -- --check
  • cargo clippy --locked --workspace --all-targets -- -D warnings (--no-default-features --features landlock,macos-sandbox,kubernetes)
  • cargo test --locked -p rustnet-core: 712 passed. test_dhcp_hostname_trailing_nuls_dropped fails on main and passes here.

Scope

  • One feature or fix per PR (no unrelated cleanups bundled in)
  • I reviewed the changes and the description matches the diff
  • No new dependencies
  • No #[allow(clippy::...)] suppressions
  • User-visible changes are added to the ## [Unreleased] section of CHANGELOG.md

Notes for the reviewer

Only trailing NULs are removed. A host name that is all NULs becomes an empty string, the same as a zero-length option today.

@domcyrus

Copy link
Copy Markdown
Owner

@JROtto5 Thanks a lot, LGTM!

@domcyrus
domcyrus merged commit 160b695 into domcyrus:main Nov 28, 2026
26 checks passed
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.

2 participants