소스 검색

fixed getdents strncpy overwrite from:https://github.com/RT-Thread/rt-thread/pull/4530

xieyangrun 4 년 전
부모
커밋
b9a410b3cf
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      dfs_lfs.c

+ 1 - 1
dfs_lfs.c

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