From 5193b5576fbe316efc43382347dfa3a6c44b03d5 Mon Sep 17 00:00:00 2001 From: Subramanian Meenakshi Sundaram Date: Fri, 8 Jun 2018 12:11:13 -0700 Subject: [PATCH] lib: posix: Fix Out-of-bound write to char array memcpy copies upto (rc-1)th index but the write of NULL character to the string is at (rc+1)th index skipping (rc)th index. The fix addresses this as well. CID: 186491 Fixes Issue #8280 Signed-off-by: Subramanian Meenakshi Sundaram --- 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 6ffc8f344dd..ba906d27f44 100644 --- a/lib/posix/fs.c +++ b/lib/posix/fs.c @@ -297,7 +297,7 @@ struct dirent *readdir(DIR *dirp) memcpy(pdirent.d_name, fdirent.name, rc); /* Make sure the name is NULL terminated */ - pdirent.d_name[rc + 1] = '\0'; + pdirent.d_name[rc] = '\0'; return &pdirent; }