Skip to content

Commit 94e6986

Browse files
authored
Use getrandom_syscall in getrandom_available
1 parent 319a426 commit 94e6986

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/linux_android_with_fallback.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
1717
}
1818

1919
fn is_getrandom_available() -> bool {
20-
let res = unsafe { getrandom(core::ptr::null_mut(), 0, libc::GRND_NONBLOCK) };
21-
if res < 0 {
20+
if getrandom_syscall(&[]) < 0 {
2221
match last_os_error().raw_os_error() {
2322
Some(libc::ENOSYS) => false, // No kernel support
2423
Some(libc::EPERM) => false, // Blocked by seccomp
@@ -28,11 +27,3 @@ fn is_getrandom_available() -> bool {
2827
true
2928
}
3029
}
31-
32-
unsafe fn getrandom(
33-
buf: *mut libc::c_void,
34-
buflen: libc::size_t,
35-
flags: libc::c_uint,
36-
) -> libc::ssize_t {
37-
libc::syscall(libc::SYS_getrandom, buf, buflen, flags) as libc::ssize_t
38-
}

0 commit comments

Comments
 (0)