You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In api/ruxos_posix_api/src/imp/getrandom.rs, it is implemented as:
/// Fills the buffer pointed to by buf with up to buflen random bytes.pubunsafeextern"C"fnsys_getrandom(buf:*mutc_void,buflen:size_t,flags:c_int) -> ssize_t{info!("sys_getrandom <= buf: {:?}, buflen: {}, flags: {}",
buf, buflen, flags
);syscall_body!(sys_getrandom,{if buf.is_null(){returnErr(LinuxError::EFAULT);}// BUG: flags are implemented wrongly, flags should be checks bit by bitmatch flags as _ {crate::ctypes::GRND_NONBLOCK => {}crate::ctypes::GRND_RANDOM => {}
_ => returnErr(LinuxError::EINVAL),}// fill the buffer 8 bytes at a time first, then fill the remaining byteslet buflen_mod = buflen % (core::mem::size_of::<i64>() / core::mem::size_of::<u8>());let buflen_div = buflen / (core::mem::size_of::<i64>() / core::mem::size_of::<u8>());for i in 0..buflen_div {*((buf as*mutu8as*muti64).add(i)) = sys_random()asi64;}for i in 0..buflen_mod {*((buf as*mutu8).add(buflen - buflen_mod + i)) = sys_rand()asu8;}Ok(buflen as ssize_t)})}
Obviously, the flag is checked as:
match flags as_{crate::ctypes::GRND_NONBLOCK => {}crate::ctypes::GRND_RANDOM => {}
_ => returnErr(LinuxError::EINVAL),}
In
api/ruxos_posix_api/src/imp/getrandom.rs
, it is implemented as:Obviously, the flag is checked as:
This will make errors like below happens:
The text was updated successfully, but these errors were encountered: