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 2021/12/29 14:01:04 UTC

[GitHub] [incubator-nuttx] normanr commented on a change in pull request #5108: Change fs strncpy to strlcpy to avoid losing'\0'

normanr commented on a change in pull request #5108:
URL: https://github.com/apache/incubator-nuttx/pull/5108#discussion_r776340258



##########
File path: fs/binfs/fs_binfs.c
##########
@@ -326,7 +326,7 @@ static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
 
       finfo("Entry %d: \"%s\"\n", index, name);
       dir->fd_dir.d_type = DTYPE_FILE;
-      strncpy(dir->fd_dir.d_name, name, NAME_MAX);
+      strlcpy(dir->fd_dir.d_name, name, NAME_MAX);

Review comment:
       Should these all be `NAME_MAX + 1` because strlcpy copies at most `dsize-1` and `d_name` is defined as with a size of `NAME_MAX + 1`?




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