From: Rich Felker Date: Fri, 22 Jul 2011 01:15:14 +0000 (-0400) Subject: fix errno value when fdopendir is given an invalid file descriptor X-Git-Tag: v0.8.0~94 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=fa845669ce03c26c069fc34e7377b47fac23edd8;p=oweals%2Fmusl.git fix errno value when fdopendir is given an invalid file descriptor this resolves an issue reported by Vasiliy Kulikov --- diff --git a/src/dirent/fdopendir.c b/src/dirent/fdopendir.c index c4b8e61d..c684a866 100644 --- a/src/dirent/fdopendir.c +++ b/src/dirent/fdopendir.c @@ -12,7 +12,10 @@ 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 (!S_ISDIR(st.st_mode)) { errno = ENOTDIR; return 0; }