4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-18 12:29:32 +08:00

* syscalls.cc (_unlink): Correct (?) logic which determines when to report an

access violation and when to queue file for eventual deletion.
(stat_worker): Check for invalid buf argument.
This commit is contained in:
Christopher Faylor 2001-07-13 17:22:15 +00:00
parent 0b4bfdd527
commit 2aa2adb2d2
2 changed files with 26 additions and 16 deletions

View File

@ -1,3 +1,10 @@
Fri Jul 13 13:13:09 2001 Christopher Faylor <cgf@cygnus.com>
* syscalls.cc (_unlink): Correct (?) logic which determines when
to report an access violation and when to queue file for eventual
deletion.
(stat_worker): Check for invalid buf argument.
Tue Jul 10 23:01:00 2001 Corinna Vinschen <corinna@vinschen.de> Tue Jul 10 23:01:00 2001 Corinna Vinschen <corinna@vinschen.de>
* mmap.cc (fhandler_disk_file::mmap): Try to open file mappings * mmap.cc (fhandler_disk_file::mmap): Try to open file mappings
@ -23,8 +30,8 @@ Wed Jun 27 22:19:07 2001 Christopher Faylor <cgf@cygnus.com>
retrieving info about remote shares can take some time. retrieving info about remote shares can take some time.
Wed Jun 27 23:30:00 2001 Robert Collins <rbtcollins@hotmail.com> Wed Jun 27 23:30:00 2001 Robert Collins <rbtcollins@hotmail.com>
Christopher Faylor <cgf@cygnus.com> Christopher Faylor <cgf@cygnus.com>
Change check_null_empty_path* to check_null_empty_str* throughout. Change check_null_empty_path* to check_null_empty_str* throughout.
* path.h (check_null_empty_str_errno): Convert to a function prototype. * path.h (check_null_empty_str_errno): Convert to a function prototype.
* path.cc (check_null_empty_str): Move to miscfuncs.cc. * path.cc (check_null_empty_str): Move to miscfuncs.cc.

View File

@ -124,6 +124,13 @@ _unlink (const char *ourname)
(void) chmod (win32_name, 0777); (void) chmod (win32_name, 0777);
} }
/* Windows 9x seems to report ERROR_ACCESS_DENIED rather than sharing
violation. So, set lasterr to ERROR_SHARING_VIOLATION in this case
to simplify tests. */
if (os_being_run != winNT && lasterr == ERROR_ACCESS_DENIED
&& !win32_name.isremote ())
lasterr = ERROR_SHARING_VIOLATION;
/* Tried to delete file by normal DeleteFile and by resetting protection /* Tried to delete file by normal DeleteFile and by resetting protection
and then deleting. That didn't work. and then deleting. That didn't work.
@ -161,22 +168,12 @@ _unlink (const char *ourname)
deleted by the OS. */ deleted by the OS. */
} }
/* FILE_FLAGS_DELETE_ON_CLOSE was a bust. If delete_on_close_ok is /* FILE_FLAGS_DELETE_ON_CLOSE was a bust. If this is a sharing
true then it should have worked. If it didn't work, that was an violation, then queue the file for deletion when the process
error. Windows 9x seems to return ERROR_ACCESS_DENIED in "sharing exits. Otherwise, punt. */
violation" type of situations. */ if (lasterr != ERROR_SHARING_VIOLATION)
if (delete_on_close_ok
|| (lasterr != ERROR_ACCESS_DENIED && lasterr != ERROR_SHARING_VIOLATION))
goto err; goto err;
/* Can't reliably detect sharing violations on remote shares, so if we
didn't specifically get that error, then punt. */
if (lasterr != ERROR_SHARING_VIOLATION && win32_name.isremote ())
{
syscall_printf ("access denied on remote drive");
goto err; /* Can't detect this, unfortunately */
}
syscall_printf ("couldn't delete file, err %d", lasterr); syscall_printf ("couldn't delete file, err %d", lasterr);
/* Add file to the "to be deleted" queue. */ /* Add file to the "to be deleted" queue. */
@ -1035,6 +1032,7 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
int attribute = 0; int attribute = 0;
uid_t uid; uid_t uid;
gid_t gid; gid_t gid;
int err;
UINT dtype; UINT dtype;
fhandler_disk_file fh (NULL); fhandler_disk_file fh (NULL);
@ -1052,6 +1050,11 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
goto done; goto done;
} }
if ((err = check_null_invalid_struct_errno (buf)))
{
set_errno (err);
goto done;
}
memset (buf, 0, sizeof (struct stat)); memset (buf, 0, sizeof (struct stat));
if (real_path.is_device ()) if (real_path.is_device ())