X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fdirent%2Ffdopendir.c;h=d78fb87f9bc909dcbf4a81a779a76dcb89696b17;hb=c5d118ebbcfe41d928d8ffc913bc532c59237189;hp=c4b8e61d2a53a73b5eb5b34c6e7d48df1720b507;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/dirent/fdopendir.c b/src/dirent/fdopendir.c index c4b8e61d..d78fb87f 100644 --- a/src/dirent/fdopendir.c +++ b/src/dirent/fdopendir.c @@ -3,8 +3,6 @@ #include #include #include -#include -#include #include "__dirent.h" DIR *fdopendir(int fd) @@ -12,7 +10,14 @@ DIR *fdopendir(int fd) DIR *dir; struct stat st; - if (fstat(fd, &st) < 0 || !S_ISDIR(st.st_mode)) { + if (fstat(fd, &st) < 0) { + return 0; + } + if (fcntl(fd, F_GETFL) & O_PATH) { + errno = EBADF; + return 0; + } + if (!S_ISDIR(st.st_mode)) { errno = ENOTDIR; return 0; }