about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoe Ellis <joe.ellis@arm.com>2020-09-10 09:11:49 +0100
committerJoe Ellis <joe.ellis@arm.com>2020-09-14 10:31:56 +0100
commit68ff495afa7687677cf9facf83c5130db24d3acd (patch)
treec001276b564eaabd660183aaae875fe6748f9cfb
parent72eef6168f2a5427ccd398a60db7ee56e419b393 (diff)
downloadrust-68ff495afa7687677cf9facf83c5130db24d3acd.tar.gz
rust-68ff495afa7687677cf9facf83c5130db24d3acd.zip
Fix peer credentials for Android
-rw-r--r--library/std/src/sys/unix/ext/ucred.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/library/std/src/sys/unix/ext/ucred.rs b/library/std/src/sys/unix/ext/ucred.rs
index 97f10e52b06..ed7516c7f28 100644
--- a/library/std/src/sys/unix/ext/ucred.rs
+++ b/library/std/src/sys/unix/ext/ucred.rs
@@ -43,24 +43,23 @@ pub mod impl_linux {
     use crate::os::unix::io::AsRawFd;
     use crate::os::unix::net::UnixStream;
     use crate::{io, mem};
+    use libc::{c_void, getsockopt, socklen_t, ucred, SOL_SOCKET, SO_PEERCRED};
 
     pub fn peer_cred(socket: &UnixStream) -> io::Result<UCred> {
-        use libc::{c_void, ucred};
-
         let ucred_size = mem::size_of::<ucred>();
 
         // Trivial sanity checks.
         assert!(mem::size_of::<u32>() <= mem::size_of::<usize>());
         assert!(ucred_size <= u32::MAX as usize);
 
-        let mut ucred_size = ucred_size as u32;
+        let mut ucred_size = ucred_size as socklen_t;
         let mut ucred: ucred = ucred { pid: 1, uid: 1, gid: 1 };
 
         unsafe {
-            let ret = libc::getsockopt(
+            let ret = getsockopt(
                 socket.as_raw_fd(),
-                libc::SOL_SOCKET,
-                libc::SO_PEERCRED,
+                SOL_SOCKET,
+                SO_PEERCRED,
                 &mut ucred as *mut ucred as *mut c_void,
                 &mut ucred_size,
             );