Skip to content

Commit

Permalink
gen_random helper: move ptr argument to front
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Aug 4, 2019
1 parent ed30152 commit 0096a0d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
/// Generate some random bytes, and write them to `dest`.
fn gen_random(
&mut self,
len: usize,
ptr: Scalar<Tag>,
len: usize,
) -> InterpResult<'tcx> {
let this = self.eval_context_mut();

Expand Down
2 changes: 1 addition & 1 deletion src/shims/dlsym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
GetEntropy => {
let ptr = this.read_scalar(args[0])?.not_undef()?;
let len = this.read_scalar(args[1])?.to_usize(this)?;
this.gen_random(len as usize, ptr)?;
this.gen_random(ptr, len as usize)?;
this.write_null(dest)?;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/shims/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
// neither of which have any effect on our current PRNG
let _flags = this.read_scalar(args[3])?.to_i32()?;

this.gen_random(len as usize, ptr)?;
this.gen_random(ptr, len as usize)?;
this.write_scalar(Scalar::from_uint(len, dest.layout.size), dest)?;
}
id => {
Expand Down Expand Up @@ -776,7 +776,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
"SecRandomCopyBytes" => {
let len = this.read_scalar(args[1])?.to_usize(this)?;
let ptr = this.read_scalar(args[2])?.not_undef()?;
this.gen_random(len as usize, ptr)?;
this.gen_random(ptr, len as usize)?;
this.write_null(dest)?;
}

Expand Down Expand Up @@ -938,7 +938,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
"SystemFunction036" => {
let ptr = this.read_scalar(args[0])?.not_undef()?;
let len = this.read_scalar(args[1])?.to_u32()?;
this.gen_random(len as usize, ptr)?;
this.gen_random(ptr, len as usize)?;
this.write_scalar(Scalar::from_bool(true), dest)?;
}

Expand Down

0 comments on commit 0096a0d

Please sign in to comment.