fix errno value when fdopendir is given an invalid file descriptor

this resolves an issue reported by Vasiliy Kulikov
This commit is contained in:
Rich Felker 2011-07-21 21:15:14 -04:00
parent 4ec07e1f60
commit fa845669ce

View File

@ -12,7 +12,10 @@ DIR *fdopendir(int fd)
DIR *dir; DIR *dir;
struct stat st; struct stat st;
if (fstat(fd, &st) < 0 || !S_ISDIR(st.st_mode)) { if (fstat(fd, &st) < 0) {
return 0;
}
if (!S_ISDIR(st.st_mode)) {
errno = ENOTDIR; errno = ENOTDIR;
return 0; return 0;
} }