From 06ceed1afb449cf80bf8f5724c4916ed31446c48 Mon Sep 17 00:00:00 2001 From: fangpeina Date: Tue, 21 Jul 2026 14:50:59 +0800 Subject: [PATCH] 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 --- system/fastboot/fastboot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/fastboot/fastboot.c b/system/fastboot/fastboot.c index 8c7448e3e..6af3ba3aa 100644 --- a/system/fastboot/fastboot.c +++ b/system/fastboot/fastboot.c @@ -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; }