Skip to content

net: reject oversized messages instead of truncating the TCP length prefix (backport) - #4145

Merged
djc merged 1 commit into
hickory-dns:release/0.26from
b84330808:tcp-length-prefix-overflow-0.26
Nov 5, 2026
Merged

djc merged 1 commit into
hickory-dns:release/0.26from
b84330808:tcp-length-prefix-overflow-0.26

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

Backport of #4144 to release/0.26, as suggested there. Clean cherry-pick; cargo test -p hickory-net --lib tcp passes.

…refix

TcpStream wrote `buffer.len() as u16` as the 2-byte length prefix, so a
message longer than 65535 bytes got a wrapped length followed by the full
payload. The peer then splits the stream at the wrong place and parses
the rest of the payload as further messages.

Return an InvalidData error for such messages instead, the same way the
QUIC stream already rejects them with u16::try_from.
@djc
djc enabled auto-merge November 5, 2026 08:37
@djc
djc added this pull request to the merge queue Nov 5, 2026
Merged via the queue into hickory-dns:release/0.26 with commit d35c5ca Nov 5, 2026
68 of 69 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.

3 participants