You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/08/24 15:40:33 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6906: Replace all strncpy with strlcpy for safety

xiaoxiang781216 commented on code in PR #6906:
URL: https://github.com/apache/incubator-nuttx/pull/6906#discussion_r953964173


##########
fs/smartfs/smartfs_utils.c:
##########
@@ -671,7 +670,7 @@ int smartfs_finddirentry(struct smartfs_mountpt_s *fs,
 
                           memset(direntry->name, 0,
                                  fs->fs_llformat.namesize + 1);
-                          strncpy(direntry->name, entry->name,
+                          strlcpy(direntry->name, entry->name,
                                   fs->fs_llformat.namesize);

Review Comment:
   ```suggestion
                                     fs->fs_llformat.namesize + 1);
   ```
   and remove line 671-672



##########
arch/arm/src/cxd56xx/cxd56_powermgr_procfs.c:
##########
@@ -758,7 +758,7 @@ static int cxd56_powermgr_procfs_readdir(struct fs_dirent_s *dir,
     }
 
   entry->d_type = DTYPE_FILE;
-  strncpy(entry->d_name, g_powermg_procfs_dir[procfs->index],
+  strlcpy(entry->d_name, g_powermg_procfs_dir[procfs->index],
           strlen(g_powermg_procfs_dir[procfs->index])+1);

Review Comment:
   sizeof(entry->d_name)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org