From 45ef97535ff64b22cf281c087c6bf1f603208985 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 5 May 2020 16:49:01 +0200 Subject: [PATCH] fs shim: check that mode is default --- src/shims/fs.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/shims/fs.rs b/src/shims/fs.rs index 58abf748dd5a..0de0b33fb2e2 100644 --- a/src/shims/fs.rs +++ b/src/shims/fs.rs @@ -246,18 +246,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx let flag = this.read_scalar(flag_op)?.to_i32()?; - // Check mode (size depends on platform). - // FIXME: should we do something with the mode? - match this.tcx.sess.target.target.target_os.as_str() { - "macos" => { - // FIXME: I think `mode` should be `u16` on macOS, but see - // . - // For now, just don't check on macos. - } - _ => { - this.read_scalar(mode_op)?.to_u32()?; - } - }; + // Get the mode. On macOS, the argument type `mode_t` is actually `u16`, but + // C integer promotion rules mean that on the ABI level, it gets passed as `u32` + // (see https://github.com/rust-lang/rust/issues/71915). + let mode = this.read_scalar(mode_op)?.to_u32()?; + if mode != 0o666 { + throw_unsup_format!("non-default mode 0o{:o} is not supported", mode); + } let mut options = OpenOptions::new();