summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-09-17 12:49:59 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2016-09-17 12:49:59 (GMT)
commit0b4dc4846b603025ee8da4403e87cad7739ac8f7 (patch)
tree263840dab088cf253ad63b2e670a3195a079734a /Modules
parent6d57fe1c23430d0d51de243a177670b76c37dab5 (diff)
downloadcpython-0b4dc4846b603025ee8da4403e87cad7739ac8f7.zip
cpython-0b4dc4846b603025ee8da4403e87cad7739ac8f7.tar.gz
cpython-0b4dc4846b603025ee8da4403e87cad7739ac8f7.tar.bz2
Issue #28075: Check for ERROR_ACCESS_DENIED in Windows implementation of os.stat()
Patch by Eryk Sun.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index f6f08bf..becf654 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -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;
}
}