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 12:55:31 UTC

[GitHub] [incubator-nuttx] DS-LK opened a new pull request #5108: Change fs strncpy to strlcpy to avoid losing'\0'

DS-LK opened a new pull request #5108:
URL: https://github.com/apache/incubator-nuttx/pull/5108


   Signed-off-by: zhouliang3 <zh...@xiaomi.com>
   Change-Id: I1fdc3c6752613226900460ccafb0a2271ae0d954
   
   ## Summary
   strncpy does not end with'\0', stack overflow may occur during use.
   ## Impact
   After strncpy is modified to strlcpy,'\0' will be automatically added at the end to avoid usage problems.
   ## Testing
   This modification does not affect the function.
   


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



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

Posted by GitBox <gi...@apache.org>.
DS-LK commented on a change in pull request #5108:
URL: https://github.com/apache/incubator-nuttx/pull/5108#discussion_r776630299



##########
File path: fs/userfs/fs_userfs.c
##########
@@ -228,7 +228,7 @@ static int userfs_open(FAR struct file *filep, FAR const char *relpath,
   req->oflags = oflags;
   req->mode   = mode;
 
-  strncpy(req->relpath, relpath, priv->mxwrite);
+  strlcpy(req->relpath, relpath, priv->mxwrite);

Review comment:
       all done.




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



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

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #5108:
URL: https://github.com/apache/incubator-nuttx/pull/5108#discussion_r776374151



##########
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:
       Good suggestion, please adjust patch @DS-LK .




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



[GitHub] [incubator-nuttx] xiaoxiang781216 edited a comment on pull request #5108: Change fs strncpy to strlcpy to avoid losing'\0'

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 edited a comment on pull request #5108:
URL: https://github.com/apache/incubator-nuttx/pull/5108#issuecomment-1002588087


   @DS-LK let's fix the style warning:
   ```
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:607:10: error: Multiple data definitions
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:877:16: error: Multiple data definitions
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:941:16: error: Multiple data definitions
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:942:14: error: Multiple data definitions
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:943:16: error: Multiple data definitions
   ```


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



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

Posted by GitBox <gi...@apache.org>.
DS-LK commented on a change in pull request #5108:
URL: https://github.com/apache/incubator-nuttx/pull/5108#discussion_r776543858



##########
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:
       OK.




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



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #5108: Change fs strncpy to strlcpy to avoid losing'\0'

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #5108:
URL: https://github.com/apache/incubator-nuttx/pull/5108


   


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



[GitHub] [incubator-nuttx] xiaoxiang781216 edited a comment on pull request #5108: Change fs strncpy to strlcpy to avoid losing'\0'

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 edited a comment on pull request #5108:
URL: https://github.com/apache/incubator-nuttx/pull/5108#issuecomment-1002588087


   @DS-LK let's fix the style warning:
   ```
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:607:10: error: Multiple data definitions
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:877:16: error: Multiple data definitions
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:941:16: error: Multiple data definitions
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:942:14: error: Multiple data definitions
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:943:16: error: Multiple data definitions
   ```
   and fill the follow macros after https://github.com/apache/incubator-nuttx/blob/master/tools/nxstyle.c#L256-L277:
   ```
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:927:12: error: Mixed case identifier found
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1099:16: error: Mixed case identifier found
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1543:13: error: Mixed case identifier found
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1941:11: error: Mixed case identifier found
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1942:11: error: Mixed case identifier found
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1953:8: error: Mixed case identifier found
   Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1974:42: error: Mixed case identifier found
   ```


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



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

Posted by GitBox <gi...@apache.org>.
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



[GitHub] [incubator-nuttx] DS-LK commented on pull request #5108: Change fs strncpy to strlcpy to avoid losing'\0'

Posted by GitBox <gi...@apache.org>.
DS-LK commented on pull request #5108:
URL: https://github.com/apache/incubator-nuttx/pull/5108#issuecomment-1002597031


   > @DS-LK let's fix the style warning:
   > 
   > ```
   > Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:607:10: error: Multiple data definitions
   > Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:877:16: error: Multiple data definitions
   > Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:941:16: error: Multiple data definitions
   > Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:942:14: error: Multiple data definitions
   > Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/smartfs/smartfs_procfs.c:943:16: error: Multiple data definitions
   > ```
   > 
   > and fill the follow macros after https://github.com/apache/incubator-nuttx/blob/master/tools/nxstyle.c#L256-L277:
   > 
   > ```
   > Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:927:12: error: Mixed case identifier found
   > Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1099:16: error: Mixed case identifier found
   > Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1543:13: error: Mixed case identifier found
   > Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1941:11: error: Mixed case identifier found
   > Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1942:11: error: Mixed case identifier found
   > Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1953:8: error: Mixed case identifier found
   > Error: /home/runner/work/incubator-nuttx/incubator-nuttx/nuttx/fs/nfs/nfs_vfsops.c:1974:42: error: Mixed case identifier found
   > ```
   
   thank you. done. 


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



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

Posted by GitBox <gi...@apache.org>.
DS-LK commented on a change in pull request #5108:
URL: https://github.com/apache/incubator-nuttx/pull/5108#discussion_r776549679



##########
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:
       Done.




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



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

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #5108:
URL: https://github.com/apache/incubator-nuttx/pull/5108#discussion_r776585684



##########
File path: fs/nfs/nfs_vfsops.c
##########
@@ -2006,7 +2006,7 @@ static int nfs_bind(FAR struct inode *blkdriver, FAR const void *data,
   nmp->nm_rsize       = nprmt.rsize;
   nmp->nm_readdirsize = nprmt.readdirsize;
 
-  strncpy(nmp->nm_path, argp->path, 90);
+  strlcpy(nmp->nm_path, argp->path, 90);

Review comment:
       90->sizeof(nmp->nm_path)

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

Review comment:
       remove

##########
File path: fs/hostfs/hostfs.c
##########
@@ -1344,9 +1344,9 @@ int hostfs_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
 
   /* Append to the host's root directory */
 
-  strncpy(oldpath, fs->fs_root, sizeof(oldpath));
+  strlcpy(oldpath, fs->fs_root, sizeof(oldpath));
   strncat(oldpath, oldrelpath, sizeof(oldpath)-strlen(oldpath)-1);
-  strncpy(newpath, fs->fs_root, sizeof(newpath));
+  strlcpy(newpath, fs->fs_root, sizeof(newpath));
   strncat(newpath, newrelpath, sizeof(newpath)-strlen(newpath)-1);

Review comment:
       strlcat(newpath, newrelpath, sizeof(newpath));

##########
File path: fs/userfs/fs_userfs.c
##########
@@ -1938,8 +1938,8 @@ static int userfs_rename(FAR struct inode *mountpt,
   req->req       = USERFS_REQ_RENAME;
   req->newoffset = oldpathlen;
 
-  strncpy(req->oldrelpath, oldrelpath, oldpathlen);
-  strncpy(&req->oldrelpath[oldpathlen], newrelpath, newpathlen);
+  strlcpy(req->oldrelpath, oldrelpath, oldpathlen);
+  strlcpy(&req->oldrelpath[oldpathlen], newrelpath, newpathlen);

Review comment:
       revert, don't need change

##########
File path: fs/userfs/fs_userfs.c
##########
@@ -228,7 +228,7 @@ static int userfs_open(FAR struct file *filep, FAR const char *relpath,
   req->oflags = oflags;
   req->mode   = mode;
 
-  strncpy(req->relpath, relpath, priv->mxwrite);
+  strlcpy(req->relpath, relpath, priv->mxwrite);

Review comment:
       revert, don't need change

##########
File path: fs/rpmsgfs/rpmsgfs.c
##########
@@ -1362,9 +1362,9 @@ int rpmsgfs_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
 
   /* Append to the host's root directory */
 
-  strncpy(oldpath, fs->fs_root, sizeof(oldpath));
+  strlcpy(oldpath, fs->fs_root, sizeof(oldpath));
   strncat(oldpath, oldrelpath, sizeof(oldpath)-strlen(oldpath)-1);
-  strncpy(newpath, fs->fs_root, sizeof(newpath));
+  strlcpy(newpath, fs->fs_root, sizeof(newpath));
   strncat(newpath, newrelpath, sizeof(newpath)-strlen(newpath)-1);

Review comment:
       strlcat(newpath, newrelpath, sizeof(newpath));

##########
File path: fs/nfs/rpc_clnt.c
##########
@@ -588,7 +588,7 @@ int rpcclnt_connect(FAR struct rpcclnt *rpc)
 
   /* Do RPC to mountd. */
 
-  strncpy(request.mountd.mount.rpath, rpc->rc_path, 90);
+  strlcpy(request.mountd.mount.rpath, rpc->rc_path, 90);

Review comment:
       90->sizeof(request.mountd.mount.rpath)

##########
File path: fs/smartfs/smartfs_utils.c
##########
@@ -1056,7 +1055,7 @@ int smartfs_createentry(FAR struct smartfs_mountpt_s *fs,
   entry->utc = time(NULL);
 #endif
   memset(entry->name, 0, fs->fs_llformat.namesize);

Review comment:
       remove

##########
File path: fs/vfs/fs_readlink.c
##########
@@ -107,7 +107,7 @@ ssize_t readlink(FAR const char *path, FAR char *buf, size_t bufsize)
   /* Copy the link target pathto the user-provided buffer. */
 
   *buf = '\0';

Review comment:
       remove

##########
File path: fs/nfs/rpc_clnt.c
##########
@@ -716,7 +716,7 @@ void rpcclnt_disconnect(FAR struct rpcclnt *rpc)
 
   /* Do RPC to umountd. */
 
-  strncpy(request.mountd.umount.rpath, rpc->rc_path, 90);
+  strlcpy(request.mountd.umount.rpath, rpc->rc_path, 90);

Review comment:
       90->sizeof(request.mountd.mount.rpath)

##########
File path: fs/hostfs/hostfs.c
##########
@@ -1344,9 +1344,9 @@ int hostfs_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
 
   /* Append to the host's root directory */
 
-  strncpy(oldpath, fs->fs_root, sizeof(oldpath));
+  strlcpy(oldpath, fs->fs_root, sizeof(oldpath));
   strncat(oldpath, oldrelpath, sizeof(oldpath)-strlen(oldpath)-1);

Review comment:
       strlcat(oldpath, oldrelpath, sizeof(oldpath));

##########
File path: fs/rpmsgfs/rpmsgfs_client.c
##########
@@ -587,7 +586,7 @@ int rpmsgfs_client_bind(FAR void **handle, FAR const char *cpuname)
       return -ENOMEM;
     }
 
-  strncpy(priv->cpuname, cpuname, RPMSG_NAME_SIZE);
+  strlcpy(priv->cpuname, cpuname, RPMSG_NAME_SIZE);

Review comment:
       RPMSG_NAME_SIZE->sizeof(priv->cpuname)

##########
File path: fs/userfs/fs_userfs.c
##########
@@ -1108,7 +1108,7 @@ static int userfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
   req      = (FAR struct userfs_opendir_request_s *)priv->iobuffer;
   req->req = USERFS_REQ_OPENDIR;
 
-  strncpy(req->relpath, relpath, priv->mxwrite);
+  strlcpy(req->relpath, relpath, priv->mxwrite);

Review comment:
       revert, don't need change

##########
File path: fs/smartfs/smartfs_utils.c
##########
@@ -1102,7 +1101,7 @@ int smartfs_createentry(FAR struct smartfs_mountpt_s *fs,
     }
 
   memset(direntry->name, 0, fs->fs_llformat.namesize + 1);

Review comment:
       remove

##########
File path: fs/rpmsgfs/rpmsgfs.c
##########
@@ -1362,9 +1362,9 @@ int rpmsgfs_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
 
   /* Append to the host's root directory */
 
-  strncpy(oldpath, fs->fs_root, sizeof(oldpath));
+  strlcpy(oldpath, fs->fs_root, sizeof(oldpath));
   strncat(oldpath, oldrelpath, sizeof(oldpath)-strlen(oldpath)-1);

Review comment:
       strlcat(oldpath, oldrelpath, sizeof(oldpath));

##########
File path: fs/userfs/fs_userfs.c
##########
@@ -1674,7 +1674,7 @@ static int userfs_unlink(FAR struct inode *mountpt,
   req      = (FAR struct userfs_unlink_request_s *)priv->iobuffer;
   req->req = USERFS_REQ_UNLINK;
 
-  strncpy(req->relpath, relpath, priv->mxwrite);
+  strlcpy(req->relpath, relpath, priv->mxwrite);

Review comment:
       revert, don't need change

##########
File path: fs/userfs/fs_userfs.c
##########
@@ -1847,7 +1847,7 @@ static int userfs_rmdir(FAR struct inode *mountpt,
   req      = (FAR struct userfs_rmdir_request_s *)priv->iobuffer;
   req->req = USERFS_REQ_RMDIR;
 
-  strncpy(req->relpath, relpath, priv->mxwrite);
+  strlcpy(req->relpath, relpath, priv->mxwrite);

Review comment:
       revert, don't need change

##########
File path: fs/userfs/fs_userfs.c
##########
@@ -2117,7 +2117,7 @@ static int userfs_chstat(FAR struct inode *mountpt, FAR const char *relpath,
   req->buf   = *buf;
   req->flags = flags;
 
-  strncpy(req->relpath, relpath, priv->mxwrite);
+  strlcpy(req->relpath, relpath, priv->mxwrite);

Review comment:
       revert, don't need change

##########
File path: fs/userfs/fs_userfs.c
##########
@@ -1761,7 +1761,7 @@ static int userfs_mkdir(FAR struct inode *mountpt,
   req->req  = USERFS_REQ_MKDIR;
   req->mode = mode;
 
-  strncpy(req->relpath, relpath, priv->mxwrite);
+  strlcpy(req->relpath, relpath, priv->mxwrite);

Review comment:
       revert, don't need change

##########
File path: fs/userfs/fs_userfs.c
##########
@@ -2025,7 +2025,7 @@ static int userfs_stat(FAR struct inode *mountpt, FAR const char *relpath,
   req      = (FAR struct userfs_stat_request_s *)priv->iobuffer;
   req->req = USERFS_REQ_STAT;
 
-  strncpy(req->relpath, relpath, priv->mxwrite);
+  strlcpy(req->relpath, relpath, priv->mxwrite);

Review comment:
       revert, don't need change




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



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

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #5108:
URL: https://github.com/apache/incubator-nuttx/pull/5108#issuecomment-1002588087


   Let's ignore the false style warning.


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



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

Posted by GitBox <gi...@apache.org>.
normanr commented on a change in pull request #5108:
URL: https://github.com/apache/incubator-nuttx/pull/5108#discussion_r776342120



##########
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:
       Actually there's a better way, use `sizeof()`, that way seems less error prone.




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