@@ -30,9 +30,8 @@ pub trait FileDescription: std::fmt::Debug + Any {
30
30
& self ,
31
31
_self_ref : & FileDescriptionRef ,
32
32
_communicate_allowed : bool ,
33
- _bytes : & mut [ u8 ] ,
34
- _len : usize ,
35
33
_ptr : Pointer ,
34
+ _len : u64 ,
36
35
_dest : & MPlaceTy < ' tcx > ,
37
36
_ecx : & mut MiriInterpCx < ' tcx > ,
38
37
) -> InterpResult < ' tcx > {
@@ -56,9 +55,9 @@ pub trait FileDescription: std::fmt::Debug + Any {
56
55
fn pread < ' tcx > (
57
56
& self ,
58
57
_communicate_allowed : bool ,
59
- _bytes : & mut [ u8 ] ,
60
58
_offset : u64 ,
61
59
_ptr : Pointer ,
60
+ _len : u64 ,
62
61
_dest : & MPlaceTy < ' tcx > ,
63
62
_ecx : & mut MiriInterpCx < ' tcx > ,
64
63
) -> InterpResult < ' tcx > {
@@ -132,18 +131,18 @@ impl FileDescription for io::Stdin {
132
131
& self ,
133
132
_self_ref : & FileDescriptionRef ,
134
133
communicate_allowed : bool ,
135
- bytes : & mut [ u8 ] ,
136
- _len : usize ,
137
134
ptr : Pointer ,
135
+ len : u64 ,
138
136
dest : & MPlaceTy < ' tcx > ,
139
137
ecx : & mut MiriInterpCx < ' tcx > ,
140
138
) -> InterpResult < ' tcx > {
139
+ let mut bytes = vec ! [ 0 ; usize :: try_from( len) . unwrap( ) ] ;
141
140
if !communicate_allowed {
142
141
// We want isolation mode to be deterministic, so we have to disallow all reads, even stdin.
143
142
helpers:: isolation_abort_error ( "`read` from stdin" ) ?;
144
143
}
145
- let result = Read :: read ( & mut { self } , bytes) ;
146
- ecx. read_byte_helper ( ptr, bytes. to_vec ( ) , result, dest) ?;
144
+ let result = Read :: read ( & mut { self } , & mut bytes) ;
145
+ ecx. read_byte_helper ( ptr, bytes, result, dest) ?;
147
146
Ok ( ( ) )
148
147
}
149
148
@@ -585,18 +584,16 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
585
584
// because it was a target's `usize`. Also we are sure that its smaller than
586
585
// `usize::MAX` because it is bounded by the host's `isize`.
587
586
588
- let len = usize:: try_from ( count) . unwrap ( ) ;
589
- let mut bytes = vec ! [ 0 ; len] ;
590
587
match offset {
591
- None => fd. read ( & fd, communicate, & mut bytes , len , buf , dest, this) ?,
588
+ None => fd. read ( & fd, communicate, buf , count , dest, this) ?,
592
589
Some ( offset) => {
593
590
let Ok ( offset) = u64:: try_from ( offset) else {
594
591
let einval = this. eval_libc ( "EINVAL" ) ;
595
592
this. set_last_error ( einval) ?;
596
593
this. write_int ( -1 , dest) ?;
597
594
return Ok ( ( ) ) ;
598
595
} ;
599
- fd. pread ( communicate, & mut bytes , offset, buf, dest, this) ?
596
+ fd. pread ( communicate, offset, buf, count , dest, this) ?
600
597
}
601
598
} ;
602
599
Ok ( ( ) )
@@ -682,7 +679,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
682
679
}
683
680
}
684
681
685
-
686
682
/// This function either writes to the user supplied buffer and to dest place, or return error.
687
683
// TODO: this is only used for eventfd
688
684
fn read_byte_helper_ev (
0 commit comments