Skip to content

Commit a8979ee

Browse files
committed
fetch ERANGE value from libc
1 parent c0a6b5f commit a8979ee

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/shims/env.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
131131
// If we cannot get the current directory, we return null
132132
// FIXME: Technically we have to set the `errno` global too
133133
match env::current_dir() {
134-
Ok(cwd) =>{
134+
Ok(cwd) => {
135135
// It is not clear what happens with non-utf8 paths here
136136
let mut bytes = cwd.display().to_string().into_bytes();
137137
// If the buffer is smaller or equal than the path, we return null.
@@ -142,7 +142,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
142142
this.memory_mut().get_mut(buf.alloc_id)?.write_bytes(tcx, buf, &bytes)?;
143143
return Ok(Scalar::Ptr(buf))
144144
}
145-
this.machine.last_error = 34; // ERANGE
145+
this.machine.last_error =
146+
this
147+
.eval_path_scalar(&["libc", "ERANGE"])?
148+
.unwrap()
149+
.to_u32()?;
146150
}
147151
Err(e) => this.machine.last_error = e.raw_os_error().unwrap() as u32,
148152
}

0 commit comments

Comments
 (0)