Skip to content

Limit source names to 63 bytes so they stay null-terminated - #76

Merged
stewartadam merged 2 commits into
mainfrom
claude/project-thread-njq8b9-2-source-name-63
Nov 12, 2026
Merged

stewartadam merged 2 commits into
mainfrom
claude/project-thread-njq8b9-2-source-name-63

Conversation

@stewartadam

@stewartadam stewartadam commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

E1.31-2016 §6.2.2 requires the 64-byte Source Name field to be null-terminated, so a name can be at most 63 bytes.

  • SacnSource::new_*, with_* and set_name used to accept a 64-byte name. They sent it with no terminator, and this crate's own receiver then rejected those packets with SourceNameNotNullTerminated.
  • Packing a DataPacketFramingLayer or UniverseDiscoveryPacketFramingLayer with a name of 65 bytes or more panicked in copy_from_slice.

Changes

  • Add packet::E131_SOURCE_NAME_MAX_LENGTH (63).
  • Source creation and set_name check against it and return MalformedSourceName.
  • The data and discovery framing layer pack functions return PackInvalidData when a name is too long, instead of writing an unterminated field or panicking.
  • In the IP tests (ipv4_tests.rs, ipv6_tests.rs), several tests used to pass SacnSource the 64-byte, null-padded name that they build for the expected packet. They now pass the name without its padding. The packets on the wire are byte-for-byte the same.

Tests

New tests in tests/src_tests.rs:

  • 64-byte names are rejected by new_v4 and set_name.
  • 63-byte names are accepted and survive a pack/parse round trip.
  • pack rejects 64-byte and 65-byte names for both data and discovery packets.

cargo test passes, and so does the full ignored IPv4 suite (cargo test --test ipv4_tests -- --ignored --test-threads=1, 47/47), run locally with the same loopback setup as the Docker job. cargo clippy reports no new warnings.

E1.31-2016 Section 6.2.2 requires the 64 byte Source Name field to be
null-terminated, so a name can be at most 63 bytes. SacnSource accepted
64 byte names and sent them with no terminator, which this crate's own
receiver then rejected with SourceNameNotNullTerminated. Packing a name
of 65 bytes or more panicked.

Add E131_SOURCE_NAME_MAX_LENGTH (63), check it when creating or renaming
a source, and return PackInvalidData from the data and discovery framing
layer pack functions when a name is too long.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KzaQVQThQpmqhvLapk99Vs
These tests build the expected 64 byte source name field, padded with
nulls, and passed that same padded string to SacnSource. With the 63
byte limit the padded string is rejected. Pass the name without its
padding; the packets sent are byte-for-byte the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KzaQVQThQpmqhvLapk99Vs
@stewartadam
stewartadam merged commit 8b57afa into main Nov 12, 2026
4 checks passed
@stewartadam
stewartadam deleted the claude/project-thread-njq8b9-2-source-name-63 branch November 12, 2026 09:46
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