From fa845669ce03c26c069fc34e7377b47fac23edd8 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 21 Jul 2011 21:15:14 -0400 Subject: [PATCH] fix errno value when fdopendir is given an invalid file descriptor this resolves an issue reported by Vasiliy Kulikov --- src/dirent/fdopendir.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; } -- 2.25.1