You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/01/05 13:58:48 UTC

[incubator-nuttx] branch master updated: fs/procfs: fix readdir loss last character

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

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


The following commit(s) were added to refs/heads/master by this push:
     new f93c17b  fs/procfs: fix readdir loss last character
f93c17b is described below

commit f93c17be943d6ce2f673c569a44364547b5a328a
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Wed Jan 5 19:27:53 2022 +0800

    fs/procfs: fix readdir loss last character
    
    nsh> ls
    /proc:
     0/
     1/
     2/
     3/
     4/
     5/
     meminf
     iobinf
     f/
     ne/
     sel/
     uptim
     versio
    
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 fs/procfs/fs_procfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c
index 6a044d0..6d04af6 100644
--- a/fs/procfs/fs_procfs.c
+++ b/fs/procfs/fs_procfs.c
@@ -800,7 +800,7 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
 
               level0->lastlen = strcspn(name, "/");
               level0->lastread = name;
-              strlcpy(dir->fd_dir.d_name, name, level0->lastlen);
+              strlcpy(dir->fd_dir.d_name, name, level0->lastlen + 1);
 
               /* If the entry is a directory type OR if the reported name is
                * only a sub-string of the entry (meaning that it contains