From 0096a0df2a34b5818976ff40b6ec5b1a54ebf92f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 4 Aug 2019 14:49:10 +0200 Subject: [PATCH] gen_random helper: move ptr argument to front --- src/helpers.rs | 2 +- src/shims/dlsym.rs | 2 +- src/shims/foreign_items.rs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/helpers.rs b/src/helpers.rs index d29cc021a1..e9b09d8160 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -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, + len: usize, ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); diff --git a/src/shims/dlsym.rs b/src/shims/dlsym.rs index b859a80190..307de29f22 100644 --- a/src/shims/dlsym.rs +++ b/src/shims/dlsym.rs @@ -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)?; } } diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs index 96bc747d3e..4fc8b1d54c 100644 --- a/src/shims/foreign_items.rs +++ b/src/shims/foreign_items.rs @@ -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 => { @@ -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)?; } @@ -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)?; }