Repository navigation
fix(dpi): keep STUN SOFTWARE when the byte cap splits a character - #753
Merged
Merged
Conversation
The 128-byte cap on the SOFTWARE attribute can cut a multi-byte UTF-8 character, and from_utf8 then rejects the whole value. RFC 8489 allows fewer than 128 characters (up to 763 bytes), so a valid non-ASCII value longer than 128 bytes was dropped. Keep the complete characters before the cut; invalid UTF-8 is still rejected.
domcyrus
reviewed
Nov 26, 2026
Review feedback: check the bytes across the cap form a valid character before keeping the prefix, and use an RFC 8489-compliant 127-character fixture.
Owner
|
Thanks a lot for the fix and for following up on both review comments, @JROtto5! I added a small bound on the UTF-8 scan and a four-byte character case. All 718 core tests passed locally. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The STUN SOFTWARE attribute is capped at 128 bytes before it is decoded. If a longer value has its 128th byte inside a multi-byte UTF-8 character,
from_utf8fails and the whole value is dropped. RFC 8489 §14.14 allows fewer than 128 characters (up to 763 bytes), so a valid non-ASCII SOFTWARE value can hit this. The parser now keeps the complete characters before the cut. Invalid UTF-8 is still rejected.Verification
Run on Linux (x86_64). This machine has no libpcap or libelf headers, so the crates that link pcap and the
ebpffeature were not built. None of them changed.cargo fmt --all -- --checkcargo clippy --locked --workspace --all-targets -- -D warnings(--no-default-features --features landlock,macos-sandbox,kubernetes)cargo test --locked -p rustnet-core: 709 passed.test_software_cap_splitting_a_character_keeps_the_prefixfails onmainand passes here.test_software_cap_splitting_an_invalid_character_is_rejected(an invalid continuation right after the cap) fails on the first commit and passes here.test_software_invalid_utf8_is_rejectedpasses on both.Scope
#[allow(clippy::...)]suppressions## [Unreleased]section ofCHANGELOG.mdNotes for the reviewer
The prefix is kept only when the attribute is longer than the cap, the decode error is an incomplete sequence at the end (
error_len()isNone), and the character split by the cap is valid in the full value. An invalid byte inside the first 128 bytes, an invalid continuation after the cap, or a truncated character in a value under the cap still returnsNone.