We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 677180b commit 11db1ffCopy full SHA for 11db1ff
src/windows7.rs
@@ -25,8 +25,10 @@ const TRUE: BOOLEAN = 1u8;
25
26
pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
27
// Prevent overflow of u32
28
- for chunk in dest.chunks_mut(u32::max_value() as usize) {
29
- let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr().cast::<c_void>(), chunk.len() as u32) };
+ for chunk in dest.chunks_mut(u32::MAX as usize) {
+ #[allow(clippy::cast_possible_truncation)]
30
+ let chunk_len = chunk.len() as u32;
31
+ let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr().cast::<c_void>(), chunk_len) };
32
if ret != TRUE {
33
return Err(Error::WINDOWS_RTL_GEN_RANDOM);
34
}
0 commit comments