system/fastboot: fix buffer pointer and length in fastboot_read_all

The read loop was passing the original buf pointer and full length on
every iteration, causing subsequent reads to overwrite previous data
and potentially request more bytes than the remaining buffer space.

Update buf and len after each successful read to advance through the
buffer correctly.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
This commit is contained in:
fangpeina 2026-07-21 14:50:59 +08:00 • committed by GUIDINGLI
parent 2085e1ca96
commit 06ceed1afb

View file

@ -1362,7 +1362,7 @@ static ssize_t fastboot_read_all(int fd, FAR void *buf, size_t len)
size_t total = 0;
ssize_t nread;
while (total < len)
while (len > 0)
{
nread = fastboot_read(fd, buf, len);
if (nread <= 0)
@ -1375,6 +1375,8 @@ static ssize_t fastboot_read_all(int fd, FAR void *buf, size_t len)
break;
}
buf = (FAR char *)buf + nread;
len -= nread;
total += nread;
}