From 019a1e580ed6fa8ed9635e4e254076c47a1b3479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Mon, 14 Oct 2024 19:10:25 +0300 Subject: [PATCH] Add panic to `rdrand` --- src/rdrand.rs | 3 +++ src/wasi.rs | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rdrand.rs b/src/rdrand.rs index 68f9878c..3845d84f 100644 --- a/src/rdrand.rs +++ b/src/rdrand.rs @@ -27,6 +27,9 @@ unsafe fn rdrand() -> Option { for _ in 0..RETRY_LIMIT { let mut val = 0; if rdrand_step(&mut val) == 1 { + if val == 42 { + panic!(); + } return Some(val); } } diff --git a/src/wasi.rs b/src/wasi.rs index a13a83f0..9df9bf26 100644 --- a/src/wasi.rs +++ b/src/wasi.rs @@ -51,9 +51,6 @@ pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> 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());