@@ -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 {
@@ -563,9 +565,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
563
565
// We want to read at most `count` bytes. We are sure that `count` is not negative
564
566
// because it was a target's `usize`. Also we are sure that its smaller than
565
567
// `usize::MAX` because it is bounded by the host's `isize`.
568
+
569
+ // TODO: shouldn't pass vec, just pass pointer and write it.
566
570
let mut bytes = vec ! [ 0 ; usize :: try_from( count) . unwrap( ) ] ;
567
571
let result = match offset {
568
- None => fd. read ( & fd, communicate, & mut bytes, this) ,
572
+ None => fd. read ( & fd, communicate, & mut bytes, buf , this) ,
569
573
Some ( offset) => {
570
574
let Ok ( offset) = u64:: try_from ( offset) else {
571
575
let einval = this. eval_libc ( "EINVAL" ) ;
@@ -578,10 +582,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
578
582
579
583
// `File::read` never returns a value larger than `count`, so this cannot fail.
580
584
match result?. map ( |c| i64:: try_from ( c) . unwrap ( ) ) {
585
+ // TODO: get the byte out the result, then write the ptr.
586
+ // try to pass this the write_ptr inside write
587
+ // Pass the pointer inside the write function.
581
588
Ok ( read_bytes) => {
582
589
// If reading to `bytes` did not fail, we write those bytes to the buffer.
583
590
// Crucially, if fewer than `bytes.len()` bytes were read, only write
584
591
// that much into the output buffer!
592
+
593
+ // TODO: write to pointer here.
585
594
this. write_bytes_ptr (
586
595
buf,
587
596
bytes[ ..usize:: try_from ( read_bytes) . unwrap ( ) ] . iter ( ) . copied ( ) ,
0 commit comments