mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-10-07 22:25:12 +00:00
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:
parent
2085e1ca96
commit
06ceed1afb
1 changed files with 3 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue