Previous fhandler_base::fstat_helper() does not assume get_stat_handle()
returns NULL. Due to this, access() for network share which has not been
authenticated returns 0 (success). This patch add error handling to
fhandler_base::fstat_helper() for get_stat_handle() failure.

Fixed: 5a0d1edba4b3 ("(fhandler_base::fstat_helper): Use handle returned by 
get_stat_handle.")
Reviewed-by:
Signed-off-by: Takashi Yano <takashi.y...@nifty.ne.jp>
---
 winsup/cygwin/fhandler/disk_file.cc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/winsup/cygwin/fhandler/disk_file.cc 
b/winsup/cygwin/fhandler/disk_file.cc
index 2008fb61b..7c3c805fd 100644
--- a/winsup/cygwin/fhandler/disk_file.cc
+++ b/winsup/cygwin/fhandler/disk_file.cc
@@ -400,6 +400,11 @@ fhandler_base::fstat_helper (struct stat *buf)
   IO_STATUS_BLOCK st;
   FILE_COMPRESSION_INFORMATION fci;
   HANDLE h = get_stat_handle ();
+  if (h == NULL)
+    {
+      __seterrno ();
+      return -1;
+    }
   PFILE_ALL_INFORMATION pfai = pc.fai ();
   ULONG attributes = pc.file_attributes ();
 
-- 
2.45.1

Reply via email to