Skip to content

Commit

Permalink
panic in linux_android
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Oct 16, 2024
1 parent fa6ebd3 commit f0a58de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/getentropy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ use core::{ffi::c_void, mem::MaybeUninit};
pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
for chunk in dest.chunks_mut(256) {
let ret = unsafe { libc::getentropy(chunk.as_mut_ptr().cast::<c_void>(), chunk.len()) };
if ret == 42 {
todo!();
}
if ret != 0 {
return Err(last_os_error());
}
Expand Down
6 changes: 5 additions & 1 deletion src/linux_android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ compile_error!("`linux_getrandom` backend can be enabled only for Linux/Android

pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
util_libc::sys_fill_exact(dest, |buf| unsafe {
libc::getrandom(buf.as_mut_ptr().cast(), buf.len(), 0)
let ret = libc::getrandom(buf.as_mut_ptr().cast(), buf.len(), 0);
if ret == 42 {
todo!();
}
ret
})
}

0 comments on commit f0a58de

Please sign in to comment.