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

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


The following commit(s) were added to refs/heads/master by this push:
     new bab2b4a5f24 libc/stream: Check lowout bounds before access
bab2b4a5f24 is described below

commit bab2b4a5f24665e66dcf27ed7efede94cc94b803
Author: Old-Ding <[email protected]>
AuthorDate: Mon Jul 6 09:11:16 2026 +0800

    libc/stream: Check lowout bounds before access
    
    Check the provided length before reading the current lowoutstream byte. 
This avoids reading past zero-length or fully consumed buffers before the loop 
condition stops.
    
    Generated-by: OpenAI Codex
    Signed-off-by: Old-Ding <[email protected]>
---
 libs/libc/stream/lib_lowoutstream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libs/libc/stream/lib_lowoutstream.c 
b/libs/libc/stream/lib_lowoutstream.c
index 6fe9fbf7941..5a7b64b73c4 100644
--- a/libs/libc/stream/lib_lowoutstream.c
+++ b/libs/libc/stream/lib_lowoutstream.c
@@ -86,7 +86,7 @@ static ssize_t lowoutstream_puts(FAR struct lib_outstream_s 
*self,
   size_t idx          = 0;
   DEBUGASSERT(self);
 
-  while (str[idx] != 0 && idx < len)
+  while (idx < len && str[idx] != 0)
     {
       lowoutstream_putc(self, str[idx]);
       idx++;

Reply via email to