Skip to content

Detect incomplete IPUDPTransfer datagrams - #251

Merged
rpaulo merged 3 commits into
apple:mainfrom
danielsyauqi:codex/ipudp-transfer-integrity
Oct 14, 2026
Merged

rpaulo merged 3 commits into
apple:mainfrom
danielsyauqi:codex/ipudp-transfer-integrity

Conversation

@danielsyauqi

Copy link
Copy Markdown
Contributor

Summary

  • Reject datagrams whose received length differs from the generated payload length.
  • Exit with status 1 when a benchmark transfer fails.
  • Add a regression test for the 1,472-byte success and 1,473-byte failure boundary.

Why

IPUDPTransfer previously treated any non-nil read as a completed transfer. With a 1,473-byte payload, the receiver gets an empty datagram, but the benchmark reported success. Checking length catches empty and truncated receives without adding a byte-by-byte comparison to the timed packet loop.

Testing

  • swift test -c release
  • swift test --filter IPUDPTransferTests -Xswiftc -warnings-as-errors
  • swift format lint --strict Package.swift Sources/Tools/IPUDPTransfer/main.swift Tests/IPUDPTransferTests/IPUDPTransferTests.swift
  • Release executable: 1,472-byte payload exits 0; 1,473-byte payload exits 1; three iterations of 300 packets at 1,000 bytes exit 0.

Closes #250

@agnosticdev agnosticdev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the change. Just one comment regarding the test.

Comment thread Package.swift
@agnosticdev agnosticdev added the 🔨 semver/patch No public API change. label Oct 13, 2026
@rpaulo
rpaulo merged commit ac21b91 into apple:main Oct 14, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IPUDPTransfer reports success when an oversized payload arrives empty

4 participants