mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Issue #28075: Check for ERROR_ACCESS_DENIED in Windows implementation of os.stat()
Patch by Eryk Sun.
This commit is contained in:
parent
6d57fe1c23
commit
0b4dc4846b
3 changed files with 26 additions and 2 deletions
|
@ -1515,7 +1515,9 @@ win32_xstat_impl(const char *path, struct _Py_stat_struct *result,
|
|||
/* Either the target doesn't exist, or we don't have access to
|
||||
get a handle to it. If the former, we need to return an error.
|
||||
If the latter, we can use attributes_from_dir. */
|
||||
if (GetLastError() != ERROR_SHARING_VIOLATION)
|
||||
DWORD lastError = GetLastError();
|
||||
if (lastError != ERROR_ACCESS_DENIED &&
|
||||
lastError != ERROR_SHARING_VIOLATION)
|
||||
return -1;
|
||||
/* Could not get attributes on open file. Fall back to
|
||||
reading the directory. */
|
||||
|
@ -1525,7 +1527,7 @@ win32_xstat_impl(const char *path, struct _Py_stat_struct *result,
|
|||
if (info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
|
||||
if (traverse) {
|
||||
/* Should traverse, but could not open reparse point handle */
|
||||
SetLastError(ERROR_SHARING_VIOLATION);
|
||||
SetLastError(lastError);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue