Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid unconditional getrandom syscall creating a WasiCtx #5244

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions crates/wasi-common/cap-std-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub use clocks::clocks_ctx;
pub use sched::sched_ctx;

use crate::net::Socket;
use cap_rand::RngCore;
use cap_rand::{Rng, RngCore, SeedableRng};
use std::path::Path;
use wasi_common::{file::FileCaps, table::Table, Error, WasiCtx, WasiFile};

Expand Down Expand Up @@ -141,5 +141,6 @@ impl WasiCtxBuilder {
}

pub fn random_ctx() -> Box<dyn RngCore + Send + Sync> {
Box::new(cap_rand::std_rng_from_entropy(cap_rand::ambient_authority()))
let mut rng = cap_rand::thread_rng(cap_rand::ambient_authority());
Box::new(cap_rand::rngs::StdRng::from_seed(rng.gen()))
}