-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes for empty and multiple-entry control message buffers. (#915)
* Fixes for empty and multiple-entry control message buffers. - Fix the handling of empty buffers passed to `SendAncillaryBuffer::new` and `RecvAncillaryBuffer::new`. - Fix the buffer size computation for multiple messages to include only one copy of the padding for alignment. * Update to qemu 8.1.2. * Update to linux-raw-sys 0.4.11 In particular, this brings in sunfishcode/linux-raw-sys#92, a fix for the `CMSG_NXTHDR` macro which fixes test failures in this PR.
- Loading branch information
1 parent
1edcdfe
commit 31dfad1
Showing
7 changed files
with
617 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#[test] | ||
fn test_empty_buffers() { | ||
use rustix::fd::AsFd; | ||
use rustix::net::{RecvAncillaryBuffer, SendAncillaryBuffer, SendAncillaryMessage}; | ||
use rustix::pipe::pipe; | ||
|
||
let (_read_end, write_end) = pipe().unwrap(); | ||
let we = [write_end.as_fd()]; | ||
|
||
let mut cmsg_buffer = SendAncillaryBuffer::new(&mut []); | ||
let msg = SendAncillaryMessage::ScmRights(&we); | ||
assert!(!cmsg_buffer.push(msg)); | ||
|
||
let mut cmsg_buffer = SendAncillaryBuffer::default(); | ||
let msg = SendAncillaryMessage::ScmRights(&we); | ||
assert!(!cmsg_buffer.push(msg)); | ||
|
||
let mut cmsg_buffer = RecvAncillaryBuffer::new(&mut []); | ||
assert!(cmsg_buffer.drain().next().is_none()); | ||
|
||
let mut cmsg_buffer = RecvAncillaryBuffer::default(); | ||
assert!(cmsg_buffer.drain().next().is_none()); | ||
} | ||
|
||
#[test] | ||
fn test_buffer_sizes() { | ||
use rustix::cmsg_space; | ||
|
||
assert!(cmsg_space!(ScmRights(0)) > 0); | ||
assert!(cmsg_space!(ScmRights(1)) >= cmsg_space!(ScmRights(0))); | ||
assert!(cmsg_space!(ScmRights(2)) < cmsg_space!(ScmRights(1), ScmRights(1))); | ||
assert!(cmsg_space!(ScmRights(1)) * 2 >= cmsg_space!(ScmRights(1), ScmRights(1))); | ||
assert!(cmsg_space!(ScmRights(1), ScmRights(0)) >= cmsg_space!(ScmRights(1))); | ||
} |
This file contains 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
Oops, something went wrong.