From 5448a3893434a64d184055be81a58f47ea6af51b Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 4 Dec 2018 15:43:30 +0000 Subject: win32: fix implementation of access(2) The WIN32 implementation of access(2) didn't return: - the correct value when a directory was tested for X_OK; - the correct error code when the target existed but execute permission wasn't available. --- win32/mingw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/win32/mingw.c b/win32/mingw.c index 7568f081d..707e6a3d2 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -1142,8 +1142,11 @@ int mingw_access(const char *name, int mode) } } - if (!mingw_stat(name, &s) && S_ISREG(s.st_mode) && (s.st_mode&S_IXUSR)) { - return 0; + if (!mingw_stat(name, &s)) { + if ((s.st_mode&S_IXUSR)) { + return 0; + } + errno = EACCES; } return -1; -- cgit v1.2.3-55-g6feb