Skip to content

Commit

Permalink
Work around warning misfire
Browse files Browse the repository at this point in the history
  • Loading branch information
stouset committed Jul 12, 2018
1 parent b642892 commit cf4e731
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions sudo_pair/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,20 @@ impl Socket {
))]
pub(crate) fn peer_euid(&self) -> Result<uid_t> {
unsafe {
let cred : libc::ucred = mem::uninitialized();
let size : libc::socklen_t = mem::size_of::<libc::ucred>() as _;
let mut cred : libc::ucred = mem::uninitialized();
let mut size : libc::socklen_t = mem::size_of::<libc::ucred>() as _;

// TODO: we use a temporary variable and coercion to go from
// `&mut libc::ucred to *mut libc::ucred` as a stepping
// stone to `*mut libc::c_void` due to Rust misfiring a
// warning about trivial casts
let cred_p : *mut libc::ucred = &mut cred;

if libc::getsockopt(
self.socket.as_raw_fd(),
libc::SOL_SOCKET,
libc::SO_PEERCRED,
&mut cred as _,
cred_p as _,
&mut size,
) == -1 {
return Err(Error::last_os_error());
Expand Down

0 comments on commit cf4e731

Please sign in to comment.