fs/romfs: fix string overflow when the length of rn_name exceeds NAME_MAX + 1

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2022-04-01 11:03:56 +08:00 committed by Petro Karashchenko
parent b5fb93aefb
commit 8a80a853b7

View File

@ -870,7 +870,8 @@ static int romfs_readdir(FAR struct inode *mountpt,
#ifdef CONFIG_FS_ROMFS_CACHE_NODE
next = (*dir->u.romfs.fr_currnode)->rn_next;
strcpy(dir->fd_dir.d_name, (*dir->u.romfs.fr_currnode)->rn_name);
strlcpy(dir->fd_dir.d_name, (*dir->u.romfs.fr_currnode)->rn_name,
sizeof(dir->fd_dir.d_name));
dir->u.romfs.fr_currnode++;
#else
/* Parse the directory entry */