|
@@ -460,7 +460,10 @@ struct os_dirent *os_readdir(os_dir_t *dir)
|
|
if (!dir->cur_dirent)
|
|
if (!dir->cur_dirent)
|
|
return NULL;
|
|
return NULL;
|
|
|
|
|
|
- strncpy(dir->out.d_name, dir->cur_dirent->d_name, 255);
|
|
|
|
|
|
+ const size_t length = strlen(dir->cur_dirent->d_name);
|
|
|
|
+ if (sizeof(dir->out.d_name) <= length)
|
|
|
|
+ return NULL;
|
|
|
|
+ memcpy(dir->out.d_name, dir->cur_dirent->d_name, length + 1);
|
|
|
|
|
|
dstr_copy(&file_path, dir->path);
|
|
dstr_copy(&file_path, dir->path);
|
|
dstr_cat(&file_path, "/");
|
|
dstr_cat(&file_path, "/");
|