Skip to content

Commit

Permalink
fix(aya-sock-map): invalid transmute when calling fd
Browse files Browse the repository at this point in the history
Corrent an invalid transmutation for sock_map.
fd is already a ref of MapFd, so transmuting &fd to &SockMapFd is
equivalent to transmuting &&SockMapFd into &SockMapFd which is buggy.
  • Loading branch information
erebe authored and alessandrod committed Feb 7, 2024
1 parent 46b4805 commit c31cce4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion aya/src/maps/sock/sock_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<T: Borrow<MapData>> SockMap<T> {
let fd: &MapFd = self.inner.borrow().fd();
// TODO(https://github.com/rust-lang/rfcs/issues/3066): avoid this unsafe.
// SAFETY: `SockMapFd` is #[repr(transparent)] over `MapFd`.
unsafe { std::mem::transmute(&fd) }
unsafe { std::mem::transmute(fd) }
}
}

Expand Down

0 comments on commit c31cce4

Please sign in to comment.