Instead of strcpy which is unbounded use strlcpy to ensure that the
receiving buffer cannot be overflowed.

This issue found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodb...@linaro.org>
---
 fs/fat/fat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 89f2acbba1e..fa34ad7a501 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1391,7 +1391,7 @@ int fat_readdir(struct fs_dir_stream *dirs, struct 
fs_dirent **dentp)
                return -ENOENT;
 
        memset(dent, 0, sizeof(*dent));
-       strcpy(dent->name, dir->itr.name);
+       strlcpy(dent->name, dir->itr.name, FS_DIRENT_NAME_LEN);
        if (CONFIG_IS_ENABLED(EFI_LOADER)) {
                dent->attr = dir->itr.dent->attr;
                fat2rtc(le16_to_cpu(dir->itr.dent->cdate),

---
base-commit: 3b4604a40b9fd61b87e9d059fc56f04d36f1a380
change-id: 20250717-fsfat-a77ce8151f74

Best regards,
-- 
Andrew Goodbody <andrew.goodb...@linaro.org>

Reply via email to