Skip to content

Commit

Permalink
Fix size of tuple SocketAddress implementations
Browse files Browse the repository at this point in the history
size_of::<Self>() for these implementations includes the address length,
but we don't want to use that, only the storage part of the address.
  • Loading branch information
Thomasdezeeuw committed Dec 30, 2023
1 parent 1bb6efc commit 1178145
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ impl SocketAddress for (libc::sockaddr, libc::socklen_t) {
unsafe fn as_mut_ptr(this: &mut MaybeUninit<Self>) -> (*mut libc::sockaddr, libc::socklen_t) {
(
ptr::addr_of_mut!((*this.as_mut_ptr()).0).cast(),
size_of::<Self>() as _,
size_of::<libc::sockaddr>() as _,
)
}

Expand All @@ -1091,7 +1091,7 @@ impl SocketAddress for (libc::sockaddr_storage, libc::socklen_t) {
unsafe fn as_mut_ptr(this: &mut MaybeUninit<Self>) -> (*mut libc::sockaddr, libc::socklen_t) {
(
ptr::addr_of_mut!((*this.as_mut_ptr()).0).cast(),
size_of::<Self>() as _,
size_of::<libc::sockaddr_storage>() as _,
)
}

Expand Down Expand Up @@ -1153,7 +1153,7 @@ impl SocketAddress for (libc::sockaddr_un, libc::socklen_t) {
unsafe fn as_mut_ptr(this: &mut MaybeUninit<Self>) -> (*mut libc::sockaddr, libc::socklen_t) {
(
ptr::addr_of_mut!((*this.as_mut_ptr()).0).cast(),
size_of::<Self>() as _,
size_of::<libc::sockaddr_un>() as _,
)
}

Expand Down

0 comments on commit 1178145

Please sign in to comment.