nuttx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gn...@apache.org
Subject [incubator-nuttx] 02/03: sim: host_readdir: Ensure NUL termination when truncating d_name
Date Thu, 26 Mar 2020 02:31:43 GMT
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 <yamamoto@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 */
 


Mime
View raw message