You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/03/26 02:31:43 UTC
[incubator-nuttx] 02/03: sim: host_readdir: Ensure NUL termination
when truncating d_name
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit f89ccf873ec187a4a9b64b7fe52ce1ad563e5335
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Mar 26 09:48:50 2020 +0900
sim: host_readdir: Ensure NUL termination when truncating d_name
---
arch/sim/src/sim/up_hostfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/sim/src/sim/up_hostfs.c b/arch/sim/src/sim/up_hostfs.c
index 32b8726..2eedd9f 100644
--- a/arch/sim/src/sim/up_hostfs.c
+++ b/arch/sim/src/sim/up_hostfs.c
@@ -320,7 +320,8 @@ int host_readdir(void *dirp, struct nuttx_dirent_s *entry)
/* Copy the entry name */
- strncpy(entry->d_name, ent->d_name, sizeof(entry->d_name));
+ strncpy(entry->d_name, ent->d_name, sizeof(entry->d_name) - 1);
+ entry->d_name[sizeof(entry->d_name) - 1] = 0;
/* Map the type */