Skip to content

Commit

Permalink
Fix an incorrect lifetime in the return value of recvmsg
Browse files Browse the repository at this point in the history
Fixes #2083
  • Loading branch information
asomers committed Aug 11, 2023
1 parent 6fb3a8f commit c98b13e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
`SockaddrIn6::from<std::net::SockaddrV6>`, `IpMembershipRequest::new`, and
`Ipv6MembershipRequest::new` with future Rust versions.
([#2061](https://github.com/nix-rust/nix/pull/2061))
- Fixed an incorrect lifetime returned from `recvmsg`.
([#2095](https://github.com/nix-rust/nix/pull/2095))

### Removed

Expand Down
2 changes: 1 addition & 1 deletion src/sys/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2058,7 +2058,7 @@ fn pack_mhdr_to_send<'a, I, C, S>(
/// [recvmsg(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html)
pub fn recvmsg<'a, 'outer, 'inner, S>(fd: RawFd, iov: &'outer mut [IoSliceMut<'inner>],
mut cmsg_buffer: Option<&'a mut Vec<u8>>,
flags: MsgFlags) -> Result<RecvMsg<'a, 'inner, S>>
flags: MsgFlags) -> Result<RecvMsg<'a, 'outer, S>>
where S: SockaddrLike + 'a,
'inner: 'outer
{
Expand Down
11 changes: 4 additions & 7 deletions test/sys/test_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,10 @@ pub fn test_recvmsg_sockaddr_un() {

// Receive the message
let mut recv_buffer = [0u8; 32];
let received = socket::recvmsg(
sock.as_raw_fd(),
&mut [std::io::IoSliceMut::new(&mut recv_buffer)],
None,
MsgFlags::empty(),
)
.unwrap();
let mut iov = [std::io::IoSliceMut::new(&mut recv_buffer)];
let received =
socket::recvmsg(sock.as_raw_fd(), &mut iov, None, MsgFlags::empty())
.unwrap();
// Check the address in the received message
assert_eq!(sockaddr, received.address.unwrap());
}
Expand Down

0 comments on commit c98b13e

Please sign in to comment.