diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2000-04-26 19:28:06 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2000-04-26 19:28:06 +0400 |
commit | 88c99264487b617df9c6cfad54e9ed4cf7ecb8c0 (patch) | |
tree | d837b58502aee3253537f1eedd2db264162c92c1 /winsup/cygwin | |
parent | bb29b5f2bcb8b3c59a0967c1bfef8618d7a100ff (diff) |
* syscalls.cc (stat_worker): Previous patch could succeed
in stating a non-existant file.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 11 |
2 files changed, 11 insertions, 5 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e6e2f125f..67cbb46d1 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +Wed Apr 26 16:20:00 2000 Corinna Vinschen <corinna@vinschen.de> + + * syscalls.cc (stat_worker): Previous patch could succeed + in stating a non-existant file. + Wed Apr 26 01:07:16 2000 Christopher Faylor <cgf@cygnus.com> * exceptions.cc (interruptible): Allocate slightly more space for diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index e5f087161..d45909883 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -978,6 +978,7 @@ stat_worker (const char *caller, const char *name, struct stat *buf, int nofollow) { int res = -1; + int oret = 1; int atts; char root[MAX_PATH]; UINT dtype; @@ -1013,8 +1014,8 @@ stat_worker (const char *caller, const char *name, struct stat *buf, (os_being_run == winNT && dtype != DRIVE_NO_ROOT_DIR && dtype != DRIVE_UNKNOWN)) - && fh.open (real_path, O_RDONLY | O_BINARY | O_DIROPEN | - (nofollow ? O_NOSYMLINK : 0), 0)) + && (oret = fh.open (real_path, O_RDONLY | O_BINARY | O_DIROPEN | + (nofollow ? O_NOSYMLINK : 0), 0))) { res = fh.fstat (buf); fh.close (); @@ -1029,10 +1030,10 @@ stat_worker (const char *caller, const char *name, struct stat *buf, buf->st_nlink = (dtype == DRIVE_REMOTE ? 1 : num_entries (real_path.get_win32 ())); } - else if (atts != -1 || GetLastError () != ERROR_FILE_NOT_FOUND) + else if (atts != -1 || (!oret && get_errno () != ENOENT)) { - /* Unfortunately, the above open may fail. So we have - to care for this case here, too. */ + /* Unfortunately, the above open may fail if the file exists, though. + So we have to care for this case here, too. */ WIN32_FIND_DATA wfd; HANDLE handle; buf->st_nlink = 1; |