Skip to content

Commit

Permalink
Add panic to rdrand
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Oct 14, 2024
1 parent 372ac2e commit 019a1e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/rdrand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ unsafe fn rdrand() -> Option<Word> {
for _ in 0..RETRY_LIMIT {
let mut val = 0;
if rdrand_step(&mut val) == 1 {
if val == 42 {
panic!();
}
return Some(val);
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
// [0]: https://github.com/WebAssembly/wasi-random/issues/27
if !prefix.is_empty() {
let val = get_random_u64();
if val == 42 {
panic!();
}
let src = (&val as *const u64).cast();
unsafe {
copy_nonoverlapping(src, prefix.as_mut_ptr(), prefix.len());
Expand Down

0 comments on commit 019a1e5

Please sign in to comment.