Repository navigation
Parse only the bytes of the received datagram - #77
Open
stewartadam wants to merge 1 commit into
Open
stewartadam wants to merge 1 commit into
stewartadam wants to merge 1 commit into
Conversation
recv read each datagram into a zero-filled 1144 byte buffer and then parsed the whole buffer, ignoring how many bytes actually arrived. A datagram cut short in transit was padded out with zeros and accepted instead of being discarded as malformed. Parse only the first n bytes, through a shared parse_datagram helper used by both the Windows and Unix receivers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KzaQVQThQpmqhvLapk99Vs
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
SacnNetworkReceiver::recvreads each datagram into a zero-filled 1144-byte buffer. It then parsed the whole buffer and ignoredn, the number of bytes actually received. If a datagram was cut short in transit, the missing bytes were filled in with zeros and the packet was accepted. It should have been discarded as malformed.Both the Unix and Windows receivers now call a shared
parse_datagram(buf, n)helper. It checksnagainst the buffer size and parses only&buf[..n], so the existing PDU length checks catch truncated packets.Tests
test_parse_datagram_rejects_truncated_packet: a valid data packet parses, and the same packet missing its last 100 slots is rejected.test_parse_datagram_rejects_length_larger_than_buffer: annlarger than the buffer returnsTooManyBytesRead.cargo testandcargo clippypass on Linux, andcargo check --target x86_64-pc-windows-gnupasses for the Windows path.