about summary refs log tree commit diff
path: root/src/dirent/fdopendir.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-07-21 21:15:14 -0400
committerRich Felker <dalias@aerifal.cx>2011-07-21 21:15:14 -0400
commitfa845669ce03c26c069fc34e7377b47fac23edd8 (patch)
tree853d9164a980fc6217fad3762dc41575b8f20717 /src/dirent/fdopendir.c
parent4ec07e1f60128cdac63bd98e7091240d6e5d888c (diff)
downloadmusl-fa845669ce03c26c069fc34e7377b47fac23edd8.tar.gz
musl-fa845669ce03c26c069fc34e7377b47fac23edd8.tar.xz
musl-fa845669ce03c26c069fc34e7377b47fac23edd8.zip
fix errno value when fdopendir is given an invalid file descriptor
this resolves an issue reported by Vasiliy Kulikov
Diffstat (limited to 'src/dirent/fdopendir.c')
-rw-r--r--src/dirent/fdopendir.c5
1 files changed, 4 insertions, 1 deletions
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;
 	}