sim: host_readdir: Ensure NUL termination when truncating d_name

This commit is contained in:
YAMAMOTO Takashi 2020-03-26 09:48:50 +09:00 committed by patacongo
parent c65bdde5ac
commit f89ccf873e

View File

@ -320,7 +320,8 @@ int host_readdir(void *dirp, struct nuttx_dirent_s *entry)
/* Copy the entry name */ /* 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 */ /* Map the type */