Skip to content

Commit

Permalink
Add check for other variadic functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tiif committed Jan 4, 2025
1 parent 3d062c1 commit d1e50d6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/shims/unix/android/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn prctl<'tcx>(
// We do not use `check_shim` here because `prctl` is variadic. The argument
// count is checked bellow.
ecx.check_abi_and_shim_symbol_clash(abi, Conv::C, link_name)?;
ecx.check_fixed_args_count("prctl", abi, 1)?;

// FIXME: Use constants once https://github.com/rust-lang/libc/pull/3941 backported to the 0.2 branch.
let pr_set_name = 15;
Expand Down
1 change: 1 addition & 0 deletions src/shims/unix/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
// `fcntl` is variadic. The argument count is checked based on the first argument
// in `this.fcntl()`, so we do not use `check_shim` here.
this.check_abi_and_shim_symbol_clash(abi, Conv::C , link_name)?;
this.check_fixed_args_count("fcntl", abi, 2)?;
let result = this.fcntl(args)?;
this.write_scalar(result, dest)?;
}
Expand Down
1 change: 1 addition & 0 deletions src/shims/unix/linux_like/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn syscall<'tcx>(
// We do not use `check_shim` here because `syscall` is variadic. The argument
// count is checked bellow.
ecx.check_abi_and_shim_symbol_clash(abi, Conv::C, link_name)?;
ecx.check_fixed_args_count("syscall", abi, 1)?;
// The syscall variadic function is legal to call with more arguments than needed,
// extra arguments are simply ignored. The important check is that when we use an
// argument, we have to also check all arguments *before* it to ensure that they
Expand Down

0 comments on commit d1e50d6

Please sign in to comment.