Use host's rng when communication is enabled
This commit is contained in:
parent
4f6f264c30
commit
b44fd97af6
@ -35,6 +35,7 @@ byteorder = { version = "1.1", features = ["i128"]}
|
||||
cargo_metadata = { version = "0.8", optional = true }
|
||||
directories = { version = "2.0", optional = true }
|
||||
rustc_version = { version = "0.2.3", optional = true }
|
||||
getrandom = "0.1.10"
|
||||
env_logger = "0.6"
|
||||
log = "0.4"
|
||||
shell-escape = "0.1.4"
|
||||
|
@ -97,9 +97,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
Align::from_bytes(1).unwrap()
|
||||
)?.expect("we already checked for size 0");
|
||||
|
||||
let rng = this.memory_mut().extra.rng.get_mut();
|
||||
let mut data = vec![0; len];
|
||||
rng.fill_bytes(&mut data);
|
||||
|
||||
if this.machine.communicate {
|
||||
// Fill the buffer using the host's rng.
|
||||
getrandom::getrandom(&mut data).map_err(|err| {
|
||||
InterpError::Unsupported(UnsupportedOpInfo::Unsupported(err.to_string()))
|
||||
})?;
|
||||
}
|
||||
else {
|
||||
let rng = this.memory_mut().extra.rng.get_mut();
|
||||
rng.fill_bytes(&mut data);
|
||||
}
|
||||
|
||||
let tcx = &{this.tcx.tcx};
|
||||
this.memory_mut().get_mut(ptr.alloc_id)?.write_bytes(tcx, ptr, &data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user