mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 04:52:02 +08:00
fs/mount: fix compiler warning found out by GCC-12.2
mount/fs_foreachmountpoint.c: In function 'mountpoint_filter':
mount/fs_foreachmountpoint.c:99:38: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
99 | sprintf(&dirpath[pathlen], "/%s", node->i_name);
| ^
In function 'mountpoint_filter',
inlined from 'mountpoint_filter' at mount/fs_foreachmountpoint.c:64:12:
mount/fs_foreachmountpoint.c:99:7: note: 'sprintf' output between 2 and 257 bytes into a destination of size 256
99 | sprintf(&dirpath[pathlen], "/%s", node->i_name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
@@ -84,8 +84,8 @@ static int mountpoint_filter(FAR struct inode *node,
|
||||
* name and the path to the directory containing the inode.
|
||||
*/
|
||||
|
||||
pathlen = strlen(dirpath);
|
||||
namlen = strlen(node->i_name) + 1;
|
||||
pathlen = strnlen(dirpath, PATH_MAX);
|
||||
namlen = strnlen(node->i_name, PATH_MAX) + 1;
|
||||
|
||||
/* Make sure that this would not exceed the maximum path length */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user