Closed MahieDev closed 6 days ago
Thanks for the PR, do you have something that might help me to reproduce this issue ?
I haven't had this error before, so this would be nice to reproduce it !
Sure, no problem. Just pushed a minimal .txt with contents "abc" to /data/local/tmp
fn main() {
let mut server = ADBServer::default();
let mut device = server.get_device().expect("cannot get device");
let stdout = io::stdout();
let mut handle = stdout.lock();
device.pull("data/local/tmp/abc.txt", &mut handle).unwrap();
}
Amazing repo btw! :)
I can indeed reproduce it. It's maybe related to the size of the file pulled, but I have to check.
Thanks for pinpointing it !
Looks like the error is related to the fact we pass buf
to read, that may have a size bigger then what we have to read.
Can you try with something like this:
let effective_read = self.inner.read(&mut buf[0..length])?;
Yeah, works perfectly, cool!
Merged, thanks for the PR ;)
Fairly new to rust, so might miss something obvious.
Nevertheless, I am experiencing an underflow when performing adb pull, as
effective_read
may be greater thanlength
.Fixed by using the length as a reference for the number of bytes to read. Again, not sure if this is the most optimal solution, but works for me.