This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 06ceed1afb449cf80bf8f5724c4916ed31446c48
Author: fangpeina <[email protected]>
AuthorDate: Tue Jul 21 14:50:59 2026 +0800

    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 <[email protected]>
---
 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;
     }
 

Reply via email to