* syscalls.cc (stat_worker): Previous patch could succeed
in stating a non-existant file.
This commit is contained in:
parent
bb29b5f2bc
commit
88c9926448
|
@ -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>
|
Wed Apr 26 01:07:16 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* exceptions.cc (interruptible): Allocate slightly more space for
|
* exceptions.cc (interruptible): Allocate slightly more space for
|
||||||
|
|
|
@ -978,6 +978,7 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
|
||||||
int nofollow)
|
int nofollow)
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
int oret = 1;
|
||||||
int atts;
|
int atts;
|
||||||
char root[MAX_PATH];
|
char root[MAX_PATH];
|
||||||
UINT dtype;
|
UINT dtype;
|
||||||
|
@ -1013,8 +1014,8 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
|
||||||
(os_being_run == winNT
|
(os_being_run == winNT
|
||||||
&& dtype != DRIVE_NO_ROOT_DIR
|
&& dtype != DRIVE_NO_ROOT_DIR
|
||||||
&& dtype != DRIVE_UNKNOWN))
|
&& dtype != DRIVE_UNKNOWN))
|
||||||
&& fh.open (real_path, O_RDONLY | O_BINARY | O_DIROPEN |
|
&& (oret = fh.open (real_path, O_RDONLY | O_BINARY | O_DIROPEN |
|
||||||
(nofollow ? O_NOSYMLINK : 0), 0))
|
(nofollow ? O_NOSYMLINK : 0), 0)))
|
||||||
{
|
{
|
||||||
res = fh.fstat (buf);
|
res = fh.fstat (buf);
|
||||||
fh.close ();
|
fh.close ();
|
||||||
|
@ -1029,10 +1030,10 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
|
||||||
buf->st_nlink =
|
buf->st_nlink =
|
||||||
(dtype == DRIVE_REMOTE ? 1 : num_entries (real_path.get_win32 ()));
|
(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
|
/* Unfortunately, the above open may fail if the file exists, though.
|
||||||
to care for this case here, too. */
|
So we have to care for this case here, too. */
|
||||||
WIN32_FIND_DATA wfd;
|
WIN32_FIND_DATA wfd;
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
buf->st_nlink = 1;
|
buf->st_nlink = 1;
|
||||||
|
|
Loading…
Reference in New Issue