Skip to content

Parse only the bytes of the received datagram - #77

Open
stewartadam wants to merge 1 commit into
mainfrom
claude/project-thread-njq8b9-3-datagram-length
Open

stewartadam wants to merge 1 commit into
mainfrom
claude/project-thread-njq8b9-3-datagram-length

Conversation

@stewartadam

@stewartadam stewartadam commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

SacnNetworkReceiver::recv reads each datagram into a zero-filled 1144-byte buffer. It then parsed the whole buffer and ignored n, 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 checks n against 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: an n larger than the buffer returns TooManyBytesRead.
  • cargo test and cargo clippy pass on Linux, and cargo check --target x86_64-pc-windows-gnu passes for the Windows path.

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
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