verify the size of all shim arguments

This commit is contained in:
Ralf Jung 2020-05-22 11:56:18 +02:00
parent 427c8a6bb8
commit fbb8c1526a
3 changed files with 7 additions and 7 deletions

View File

@ -170,7 +170,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
// Dynamic symbol loading
"dlsym" => {
let &[handle, symbol] = check_arg_count(args)?;
this.read_scalar(handle)?.not_undef()?;
this.read_scalar(handle)?.to_machine_usize(this)?;
let symbol = this.read_scalar(symbol)?.not_undef()?;
let symbol_name = this.memory.read_c_str(symbol)?;
if let Some(dlsym) = Dlsym::from_str(symbol_name, &this.tcx.sess.target.target.target_os)? {
@ -369,9 +369,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
}
"pthread_atfork" => {
let &[prepare, parent, child] = check_arg_count(args)?;
this.read_scalar(prepare)?.not_undef()?;
this.read_scalar(parent)?.not_undef()?;
this.read_scalar(child)?.not_undef()?;
this.force_bits(this.read_scalar(prepare)?.not_undef()?, this.memory.pointer_size())?;
this.force_bits(this.read_scalar(parent)?.not_undef()?, this.memory.pointer_size())?;
this.force_bits(this.read_scalar(child)?.not_undef()?, this.memory.pointer_size())?;
// We do not support forking, so there is nothing to do here.
this.write_null(dest)?;
}

View File

@ -105,13 +105,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
// Querying system information
"pthread_get_stackaddr_np" => {
let &[thread] = check_arg_count(args)?;
this.read_scalar(thread)?.not_undef()?;
this.read_scalar(thread)?.to_machine_usize(this)?;
let stack_addr = Scalar::from_uint(STACK_ADDR, this.pointer_size());
this.write_scalar(stack_addr, dest)?;
}
"pthread_get_stacksize_np" => {
let &[thread] = check_arg_count(args)?;
this.read_scalar(thread)?.not_undef()?;
this.read_scalar(thread)?.to_machine_usize(this)?;
let stack_size = Scalar::from_uint(STACK_SIZE, this.pointer_size());
this.write_scalar(stack_size, dest)?;
}

View File

@ -210,7 +210,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
"GetProcAddress" => {
#[allow(non_snake_case)]
let &[hModule, lpProcName] = check_arg_count(args)?;
this.read_scalar(hModule)?.not_undef()?;
this.read_scalar(hModule)?.to_machine_isize(this)?;
let name = this.memory.read_c_str(this.read_scalar(lpProcName)?.not_undef()?)?;
if let Some(dlsym) = Dlsym::from_str(name, &this.tcx.sess.target.target.target_os)? {
let ptr = this.memory.create_fn_alloc(FnVal::Other(dlsym));