[PATCH 1/3] Cygwin: device_access_denied: return false if O_PATH is set

Ken Brown kbrown@cornell.edu
Thu Jan 23 16:31:00 GMT 2020


If O_PATH is set in the flags argument of
fhandler_base::device_access_denied, return false.  No
read/write/execute access should be required in this case.

Previously, the call to device_access_denied in open(2) would lead to
an attempt to open the file with read access even if the O_PATH flag
was set.
---
 winsup/cygwin/fhandler.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index b0c9c50c3..aeee8fe4d 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -335,6 +335,9 @@ fhandler_base::device_access_denied (int flags)
 {
   int mode = 0;
 
+  if (flags & O_PATH)
+    return false;
+
   if (flags & O_RDWR)
     mode |= R_OK | W_OK;
   if (flags & (O_WRONLY | O_APPEND))
-- 
2.21.0



More information about the Cygwin-patches mailing list