@@ -30,9 +30,8 @@ pub trait FileDescription: std::fmt::Debug + Any {
3030 & self ,
3131 _self_ref : & FileDescriptionRef ,
3232 _communicate_allowed : bool ,
33- _bytes : & mut [ u8 ] ,
34- _len : usize ,
3533 _ptr : Pointer ,
34+ _len : u64 ,
3635 _dest : & MPlaceTy < ' tcx > ,
3736 _ecx : & mut MiriInterpCx < ' tcx > ,
3837 ) -> InterpResult < ' tcx > {
@@ -56,9 +55,9 @@ pub trait FileDescription: std::fmt::Debug + Any {
5655 fn pread < ' tcx > (
5756 & self ,
5857 _communicate_allowed : bool ,
59- _bytes : & mut [ u8 ] ,
6058 _offset : u64 ,
6159 _ptr : Pointer ,
60+ _len : u64 ,
6261 _dest : & MPlaceTy < ' tcx > ,
6362 _ecx : & mut MiriInterpCx < ' tcx > ,
6463 ) -> InterpResult < ' tcx > {
@@ -132,18 +131,18 @@ impl FileDescription for io::Stdin {
132131 & self ,
133132 _self_ref : & FileDescriptionRef ,
134133 communicate_allowed : bool ,
135- bytes : & mut [ u8 ] ,
136- _len : usize ,
137134 ptr : Pointer ,
135+ len : u64 ,
138136 dest : & MPlaceTy < ' tcx > ,
139137 ecx : & mut MiriInterpCx < ' tcx > ,
140138 ) -> InterpResult < ' tcx > {
139+ let mut bytes = vec ! [ 0 ; usize :: try_from( len) . unwrap( ) ] ;
141140 if !communicate_allowed {
142141 // We want isolation mode to be deterministic, so we have to disallow all reads, even stdin.
143142 helpers:: isolation_abort_error ( "`read` from stdin" ) ?;
144143 }
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) ?;
147146 Ok ( ( ) )
148147 }
149148
@@ -585,18 +584,16 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
585584 // because it was a target's `usize`. Also we are sure that its smaller than
586585 // `usize::MAX` because it is bounded by the host's `isize`.
587586
588- let len = usize:: try_from ( count) . unwrap ( ) ;
589- let mut bytes = vec ! [ 0 ; len] ;
590587 match offset {
591- None => fd. read ( & fd, communicate, & mut bytes , len , buf , dest, this) ?,
588+ None => fd. read ( & fd, communicate, buf , count , dest, this) ?,
592589 Some ( offset) => {
593590 let Ok ( offset) = u64:: try_from ( offset) else {
594591 let einval = this. eval_libc ( "EINVAL" ) ;
595592 this. set_last_error ( einval) ?;
596593 this. write_int ( -1 , dest) ?;
597594 return Ok ( ( ) ) ;
598595 } ;
599- fd. pread ( communicate, & mut bytes , offset, buf, dest, this) ?
596+ fd. pread ( communicate, offset, buf, count , dest, this) ?
600597 }
601598 } ;
602599 Ok ( ( ) )
@@ -682,7 +679,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
682679 }
683680 }
684681
685-
686682 /// This function either writes to the user supplied buffer and to dest place, or return error.
687683 // TODO: this is only used for eventfd
688684 fn read_byte_helper_ev (
0 commit comments