From 9d5936c04fcf5aebbdc63412033427a683b46e8d Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Thu, 21 Mar 2019 22:44:21 -0700 Subject: [PATCH] lib: posix: fs: Fix access invalid memory fs_dirent.name is MAX_FILE_NAME + 1 bytes long, not PATH_MAX. Just fixing it to avoid access invalid memory. Coverity CID: 186037 Signed-off-by: Flavio Ceolin --- lib/posix/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/posix/fs.c b/lib/posix/fs.c index b20ac0d5f4e..0f0dd9dd366 100644 --- a/lib/posix/fs.c +++ b/lib/posix/fs.c @@ -249,7 +249,7 @@ struct dirent *readdir(DIR *dirp) } rc = strlen(fdirent.name); - rc = (rc < PATH_MAX) ? rc : (PATH_MAX - 1); + rc = (rc < MAX_FILE_NAME) ? rc : (MAX_FILE_NAME - 1); (void)memcpy(pdirent.d_name, fdirent.name, rc); /* Make sure the name is NULL terminated */