@@ -31,6 +31,7 @@ pub trait FileDescription: std::fmt::Debug + Any {
31
31
_self_ref : & FileDescriptionRef ,
32
32
_communicate_allowed : bool ,
33
33
_bytes : & mut [ u8 ] ,
34
+ _ptr : Pointer ,
34
35
_ecx : & mut MiriInterpCx < ' tcx > ,
35
36
) -> InterpResult < ' tcx , io:: Result < usize > > {
36
37
throw_unsup_format ! ( "cannot read from {}" , self . name( ) ) ;
@@ -126,6 +127,7 @@ impl FileDescription for io::Stdin {
126
127
_self_ref : & FileDescriptionRef ,
127
128
communicate_allowed : bool ,
128
129
bytes : & mut [ u8 ] ,
130
+ _ptr : Pointer ,
129
131
_ecx : & mut MiriInterpCx < ' tcx > ,
130
132
) -> InterpResult < ' tcx , io:: Result < usize > > {
131
133
if !communicate_allowed {
@@ -562,9 +564,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
562
564
// We want to read at most `count` bytes. We are sure that `count` is not negative
563
565
// because it was a target's `usize`. Also we are sure that its smaller than
564
566
// `usize::MAX` because it is bounded by the host's `isize`.
567
+
568
+ // TODO: shouldn't pass vec, just pass pointer and write it.
565
569
let mut bytes = vec ! [ 0 ; usize :: try_from( count) . unwrap( ) ] ;
566
570
let result = match offset {
567
- None => fd. read ( & fd, communicate, & mut bytes, this) ,
571
+ None => fd. read ( & fd, communicate, & mut bytes, buf , this) ,
568
572
Some ( offset) => {
569
573
let Ok ( offset) = u64:: try_from ( offset) else {
570
574
let einval = this. eval_libc ( "EINVAL" ) ;
@@ -577,10 +581,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
577
581
578
582
// `File::read` never returns a value larger than `count`, so this cannot fail.
579
583
match result?. map ( |c| i64:: try_from ( c) . unwrap ( ) ) {
584
+ // TODO: get the byte out the result, then write the ptr.
585
+ // try to pass this the write_ptr inside write
586
+ // Pass the pointer inside the write function.
580
587
Ok ( read_bytes) => {
581
588
// If reading to `bytes` did not fail, we write those bytes to the buffer.
582
589
// Crucially, if fewer than `bytes.len()` bytes were read, only write
583
590
// that much into the output buffer!
591
+
592
+ // TODO: write to pointer here.
584
593
this. write_bytes_ptr (
585
594
buf,
586
595
bytes[ ..usize:: try_from ( read_bytes) . unwrap ( ) ] . iter ( ) . copied ( ) ,
0 commit comments