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.git


The following commit(s) were added to refs/heads/master by this push:
     new e973f2f269a fs/procfs: handle zero-sized procfs_snprintf buffers
e973f2f269a is described below

commit e973f2f269a45aea58b40a668ceedcc914e6b0a8
Author: jingfei <[email protected]>
AuthorDate: Fri Nov 27 03:09:13 2026 +0800

    fs/procfs: handle zero-sized procfs_snprintf buffers
    
    Return zero when procfs_snprintf is asked to format into a zero-sized
    buffer. This matches the number of bytes written by the helper and avoids
    underflowing the size limit expression.
    
    Signed-off-by: jingfei <[email protected]>
---
 fs/procfs/fs_procfsutil.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/procfs/fs_procfsutil.c b/fs/procfs/fs_procfsutil.c
index 350bc15a8b0..6bfac1db816 100644
--- a/fs/procfs/fs_procfsutil.c
+++ b/fs/procfs/fs_procfsutil.c
@@ -146,7 +146,7 @@ int procfs_snprintf(FAR char *buf, size_t size,
   va_start(ap, format);
   n = vsnprintf(buf, size, format, ap);
   va_end(ap);
-  return n < size - 1 ? n : size - 1;
+  return size > 0 && n < size - 1 ? n : size > 0 ? size - 1 : 0;
 }
 
 /****************************************************************************

Reply via email to