Skip to content

Commit

Permalink
Merge pull request #2095 from asomers/recvmsg-lifetime
Browse files Browse the repository at this point in the history
Fix an incorrect lifetime in the return value of recvmsg
  • Loading branch information
asomers authored Aug 19, 2023
2 parents 981dc1c + c98b13e commit b4836ea
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 @@ -68,6 +68,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 b4836ea

Please sign in to comment.