Skip to content

Change fs strncpy to strlcpy to avoid losing'\0' #5108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2021
Merged

Change fs strncpy to strlcpy to avoid losing'\0' #5108

merged 1 commit into from
Dec 30, 2021

Conversation

DS-LK
Copy link
Contributor

@DS-LK DS-LK commented Dec 29, 2021

Summary

strncpy does not end with'\0', stack overflow may occur during use. Report here: #5107

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.

@xiaoxiang781216
Copy link
Contributor

xiaoxiang781216 commented Dec 29, 2021

@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

@DS-LK
Copy link
Contributor Author

DS-LK commented Dec 29, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants