[bug][dfs] rt_strlen(name) + 1) -> DFS_PATH_MAX

This commit is contained in:
Meco Man 2021-03-27 01:24:32 +08:00
parent 8fccef5894
commit d1d9c492f8
3 changed files with 3 additions and 3 deletions

View File

@ -647,7 +647,7 @@ int dfs_elm_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
d->d_namlen = (rt_uint8_t)rt_strlen(fn);
d->d_reclen = (rt_uint16_t)sizeof(struct dirent);
rt_strncpy(d->d_name, fn, rt_strlen(fn) + 1);
rt_strncpy(d->d_name, fn, DFS_PATH_MAX);
index ++;
if (index * sizeof(struct dirent) >= count)

View File

@ -1119,7 +1119,7 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
d->d_namlen = rt_strlen(name);
d->d_reclen = (rt_uint16_t)sizeof(struct dirent);
rt_strncpy(d->d_name, name, rt_strlen(name) + 1);
rt_strncpy(d->d_name, name, DFS_PATH_MAX);
index ++;
if (index * sizeof(struct dirent) >= count)

View File

@ -276,7 +276,7 @@ int dfs_romfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
d->d_namlen = rt_strlen(name);
d->d_reclen = (rt_uint16_t)sizeof(struct dirent);
rt_strncpy(d->d_name, name, rt_strlen(name) + 1);
rt_strncpy(d->d_name, name, DFS_PATH_MAX);
/* move to next position */
++ file->pos;