Minor AF_INET socket conformance: SO_BROADCAST on sendto, MSG_TRUNC, SO_RCVBUF readback#860
Open
brandonpayton wants to merge 1 commit into
Open
Minor AF_INET socket conformance: SO_BROADCAST on sendto, MSG_TRUNC, SO_RCVBUF readback#860brandonpayton wants to merge 1 commit into
brandonpayton wants to merge 1 commit into
Conversation
…SO_RCVBUF readback Three small POSIX-conformance fixes to the AF_INET socket surface, each with a dedicated test: - sendto to the broadcast address (255.255.255.255) now requires SO_BROADCAST and returns EACCES without it, matching the enforcement connect() already did. - recvfrom honors MSG_TRUNC: it reports the real datagram length even when the caller buffer is too small (excess bytes are still discarded). - getsockopt(SO_RCVBUF/SO_SNDBUF) returns a previously set value instead of always returning the default, so set/get round-trips consistently. The value remains advisory (not enforced as a hard buffer size). No ABI change (MSG_TRUNC is a local constant; no new exports/imports or structs). Validation: `cargo test -p kandelo --lib` (966 pass, incl. three new tests: `test_sendto_broadcast_requires_so_broadcast`, `test_recvfrom_msg_trunc_reports_full_length`, `test_getsockopt_so_rcvbuf_reflects_set_value`). `scripts/check-abi-version.sh` in sync. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Three small POSIX-conformance fixes to the AF_INET socket surface, each with a dedicated test.
Fixes
sendto— asendtoto255.255.255.255now requiresSO_BROADCASTand returnsEACCESwithout it, matching the enforcementconnect()already did.MSG_TRUNConrecvfrom— reports the real datagram length even when the caller buffer is too small (excess bytes are still discarded, as datagram sockets are lossy).SO_RCVBUF/SO_SNDBUFreadback —getsockoptreturns a previously set value instead of always returning the default, so set/get round-trips consistently. The value remains advisory (not enforced as a hard buffer size).ABI
No change —
MSG_TRUNCis a local constant; no new exports/imports or structs.Validation
cargo test -p kandelo --target aarch64-apple-darwin --lib— 966 pass, including three new tests (test_sendto_broadcast_requires_so_broadcast,test_recvfrom_msg_trunc_reports_full_length,test_getsockopt_so_rcvbuf_reflects_set_value).scripts/check-abi-version.sh— snapshot in sync.Deliberately deferred (from the same audit, not bundled here)
listen()backlog enforcement — bounding the accept queue is a behavior change (Linux treats backlog as a hint; a hard cap risks the loopback service demos) and over-permissiveness is not a correctness break. Wants its own scoped change.MSG_OOBon loopback TCP — currently returns success but loses the urgent byte. Delivering it cross-process needs the same machinery as cross-process connect;MSG_OOBis legacy/rarely used. Wants its own change.🤖 Generated with Claude Code