Skip to content

Commit ce94b22

Browse files
committed
read off_t at the right size for the current target
1 parent 69ea952 commit ce94b22

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/tools/miri/src/shims/unix/foreign_items.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
163163
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
164164
let fd = this.read_scalar(fd)?.to_i32()?;
165165
let length = this.read_scalar(length)?.to_i64()?;
166-
let result = this.ftruncate64(fd, length)?;
166+
let result = this.ftruncate64(fd, length.into())?;
167167
this.write_scalar(result, dest)?;
168168
}
169169
"ftruncate" => {
170170
let [fd, length] =
171171
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
172172
let fd = this.read_scalar(fd)?.to_i32()?;
173-
let length = this.read_target_isize(length)?;
173+
let length = this.read_scalar(length)?.to_int(this.libc_ty_layout("off_t").size)?;
174174
let result = this.ftruncate64(fd, length)?;
175175
this.write_scalar(result, dest)?;
176176
}

src/tools/miri/src/shims/unix/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
15041504
}
15051505
}
15061506

1507-
fn ftruncate64(&mut self, fd: i32, length: i64) -> InterpResult<'tcx, Scalar<Provenance>> {
1507+
fn ftruncate64(&mut self, fd: i32, length: i128) -> InterpResult<'tcx, Scalar<Provenance>> {
15081508
let this = self.eval_context_mut();
15091509

15101510
// Reject if isolation is enabled.

0 commit comments

Comments
 (0)