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

xiaoxiang781216 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 ea14533651c fs/inode: build the foreach_inode() path without snprintf()
ea14533651c is described below

commit ea14533651c9dff3d97e3d65ddf955c97efe4b8c
Author: jingfei <[email protected]>
AuthorDate: Sun Nov 22 23:01:30 2026 +0800

    fs/inode: build the foreach_inode() path without snprintf()
    
    foreach_inodelevel() appended each path segment with snprintf("/%s").
    sync() walks the mountpoints and is always linked through the reboot
    notifier, so images that do not otherwise use printf now link the
    whole printf engine.  Copy the segment with strlcpy() instead; the
    length is already checked against PATH_MAX.
    
    Signed-off-by: jingfei <[email protected]>
---
 fs/inode/fs_foreachinode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/inode/fs_foreachinode.c b/fs/inode/fs_foreachinode.c
index 6d7e5dcefcc..e16ac91d911 100644
--- a/fs/inode/fs_foreachinode.c
+++ b/fs/inode/fs_foreachinode.c
@@ -26,7 +26,6 @@
 
 #include <nuttx/config.h>
 
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -115,8 +114,9 @@ static int foreach_inodelevel(FAR struct inode *inode,
 
           /* Append the path segment to this inode and recurse */
 
-          snprintf(&info->path[pathlen], sizeof(info->path) - pathlen,
-                   "/%s", inode->i_name);
+          info->path[pathlen] = '/';
+          strlcpy(&info->path[pathlen + 1], inode->i_name,
+                  sizeof(info->path) - pathlen - 1);
           ret = foreach_inodelevel(inode->i_child, info);
 
           /* Truncate the path name back to the correct length */

Reply via email to