feat: add ancillary data (control message) helpers for sendmsg/recvmsg#645
Open
seuros wants to merge 1 commit intorust-lang:masterfrom
Open
feat: add ancillary data (control message) helpers for sendmsg/recvmsg#645seuros wants to merge 1 commit intorust-lang:masterfrom
seuros wants to merge 1 commit intorust-lang:masterfrom
Conversation
c94de0c to
c22b136
Compare
Closes rust-lang#614 Add Unix-only safe wrappers for CMSG_* operations: - `cmsg_space(data_len) -> Option<usize>`: compute control buffer size (returns None when data_len overflows c_uint, fixing a truncation path that would produce an undersized buffer) - `ControlMessage<'a>`: a parsed ancillary data entry (level, type, data) - `ControlMessages<'a>`: iterator over a received control buffer; walks via byte-offset arithmetic and ptr::read_unaligned so no aligned reference to cmsghdr is ever formed (avoids UB on 1-byte-aligned Vec<u8> buffers) - `ControlMessageEncoder<'a>`: builder for outgoing control messages; rejects payloads exceeding c_uint::MAX before calling CMSG_SPACE/CMSG_LEN to prevent buffer overflow from silent truncation Also add a Cross CI job to run tests under QEMU on i686, aarch64, and armv7 Linux — the target families where CMSG_ALIGN factor and cmsg_len width differ from x86_64. Enables SCM_RIGHTS file-descriptor passing without depending on libc directly (tracked by plabayo/rama#781).
c22b136 to
dd9b05e
Compare
Author
|
The only remaining CI failure is FreeBSD (Cirrus CI) — this is an infrastructure flake, not a code issue: Cargo tries to update the crates.io index and hits an SSL cert verification failure in the Cirrus FreeBSD 14.3 VM. Unrelated to this PR! Verified manually on FreeBSD 16-Current where |
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.
Closes #614
Add Unix-only safe wrappers for CMSG_* operations:
cmsg_space(data_len) -> Option<usize>: compute control buffer size (returns None when data_len overflows c_uint, fixing a truncation path that would produce an undersized buffer)ControlMessage<'a>: a parsed ancillary data entry (level, type, data)ControlMessages<'a>: iterator over a received control buffer; walks via byte-offset arithmetic and ptr::read_unaligned so no aligned reference to cmsghdr is ever formed (avoids UB on 1-byte-aligned Vec buffers)ControlMessageEncoder<'a>: builder for outgoing control messages; rejects payloads exceeding c_uint::MAX before calling CMSG_SPACE/CMSG_LEN to prevent buffer overflow from silent truncationAlso add a Cross CI job to run tests under QEMU on i686, aarch64, and armv7 Linux, the target families where CMSG_ALIGN factor and cmsg_len width differ from x86_64.
Enables SCM_RIGHTS file-descriptor passing without depending on libc directly (tracked by plabayo/rama#781).
I can remove the Cross tests if needed.