lib/posix/fs: fix end-of-dir in readdir
POSIX readdir should return NULL if end of dir is reached and leave errno untouched. Signed-off-by: Rico Ganahl <rico.ganahl@bytesatwork.ch>
This commit is contained in:
parent
7e4cf8308d
commit
5cf1193902
1 changed files with 5 additions and 0 deletions
|
@ -290,6 +290,11 @@ struct dirent *readdir(DIR *dirp)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fdirent.name[0] == 0) {
|
||||||
|
/* assume end-of-dir, leave errno untouched */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
rc = strlen(fdirent.name);
|
rc = strlen(fdirent.name);
|
||||||
rc = (rc < MAX_FILE_NAME) ? rc : (MAX_FILE_NAME - 1);
|
rc = (rc < MAX_FILE_NAME) ? rc : (MAX_FILE_NAME - 1);
|
||||||
(void)memcpy(pdirent.d_name, fdirent.name, rc);
|
(void)memcpy(pdirent.d_name, fdirent.name, rc);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue