From 2c3a28373668fa94a0d4fd8cf2e838fa26a2d286 Mon Sep 17 00:00:00 2001 From: Trevor Elliott Date: Thu, 28 Sep 2023 11:34:01 -0700 Subject: [PATCH] Seed the preview2 context with the thread_rng, instead of using a syscall --- crates/wasi/src/preview2/ctx.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/wasi/src/preview2/ctx.rs b/crates/wasi/src/preview2/ctx.rs index 03b69da3b795..68d690d80c19 100644 --- a/crates/wasi/src/preview2/ctx.rs +++ b/crates/wasi/src/preview2/ctx.rs @@ -54,7 +54,9 @@ impl WasiCtxBuilder { pub fn new() -> Self { // For the insecure random API, use `SmallRng`, which is fast. It's // also insecure, but that's the deal here. - let insecure_random = Box::new(cap_rand::rngs::SmallRng::from_entropy()); + let insecure_random = Box::new(cap_rand::rngs::SmallRng::from_rng(cap_rand::thread_rng( + cap_rand::ambient_authority(), + )).unwrap()); // For the insecure random seed, use a `u128` generated from // `thread_rng()`, so that it's not guessable from the insecure_random