From 375c7faa4c9da784454ca42302ca7d59bb2c8f77 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 6 Jan 2005 17:43:55 +0000 Subject: [PATCH] * fhandler_disk_file.cc (fhandler_base::open_fs): Don't allow opening directories for writing. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/fhandler_disk_file.cc | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 0dee5fcd0..464e57da4 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2005-01-06 Corinna Vinschen + + * fhandler_disk_file.cc (fhandler_base::open_fs): Don't allow + opening directories for writing. + 2005-01-06 Christopher Faylor * timer.cc (timer_thread): Pass sigev pointer value as per SuSv3 rather diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 7fc6a14a9..1901d17e7 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -568,6 +568,14 @@ fhandler_base::open_fs (int flags, mode_t mode) return 0; } + /* Unfortunately NT allows to open directories for writing, but that's + disallowed according to SUSv3. */ + if (pc.isdir () && (flags & (O_WRONLY | O_RDWR))) + { + set_errno (EISDIR); + return 0; + } + int res = fhandler_base::open (flags | O_DIROPEN, mode); if (!res) goto out; -- 2.43.5