Skip to content
Snippets Groups Projects
Commit 24e58861 authored by Joe Richey's avatar Joe Richey Committed by Joseph Richey
Browse files

bsd_arandom: Read only 256 bytes at a time


Older NetBSD kernels cannot handle buffers bigger than 256 bytes, and
all FreeBSD and NetBSD kernels only return up to 256 bytes per call.

Signed-off-by: default avatarJoe Richey <joerichey@google.com>
parent fc837902
No related branches found
No related tags found
No related merge requests found
......@@ -43,5 +43,10 @@ pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
return sys_fill_exact(dest, |buf| unsafe { func(buf.as_mut_ptr(), buf.len(), 0) });
}
}
sys_fill_exact(dest, kern_arnd)
// Both FreeBSD and NetBSD will only return up to 256 bytes at a time, and
// older NetBSD kernels will fail on longer buffers.
for chunk in dest.chunks_mut(256) {
sys_fill_exact(chunk, kern_arnd)?
}
Ok(())
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment