From d417aec9089e59f0f667290ebe777ef554ac5103 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 5 Nov 2003 16:53:55 +0000 Subject: [PATCH] * fhandler_disk_file.cc (fhandler_disk_file::opendir): Detect attempt to open a directory which lacks read privileges. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/fhandler_disk_file.cc | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 4bc145fab..90d989cf3 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2003-11-05 Christopher Faylor + + * fhandler_disk_file.cc (fhandler_disk_file::opendir): Detect attempt + to open a directory which lacks read privileges. + 2003-11-04 Corinna Vinschen * external.cc (cygwin_internal): Add CW_GET_POSIX_SECURITY_ATTRIBUTE diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 1c11636e9..20ed66124 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -617,15 +617,20 @@ fhandler_disk_file::opendir () set_errno (ENOMEM); else if ((dir->__d_dirname = (char *) malloc (len + 3)) == NULL) { - free (dir); set_errno (ENOMEM); + free (dir); } else if ((dir->__d_dirent = (struct dirent *) malloc (sizeof (struct dirent))) == NULL) { + set_errno (ENOMEM); + free (dir); free (dir->__d_dirname); + } + else if (access_worker (pc, R_OK) != 0) + { free (dir); - set_errno (ENOMEM); + free (dir->__d_dirname); } else { -- 2.43.5