summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrian Curtin <brian@python.org>2011-06-14 14:52:50 (GMT)
committerBrian Curtin <brian@python.org>2011-06-14 14:52:50 (GMT)
commitc8be84077bbd87e80b1697db6dbfe0fc6e5cbc2b (patch)
tree44fe7c27720b8eb1c88d1fa54470993f028dc809 /Modules
parenta87d586fd6c4a5dfe4ea89fda288ae8eb66b0134 (diff)
downloadcpython-c8be84077bbd87e80b1697db6dbfe0fc6e5cbc2b.zip
cpython-c8be84077bbd87e80b1697db6dbfe0fc6e5cbc2b.tar.gz
cpython-c8be84077bbd87e80b1697db6dbfe0fc6e5cbc2b.tar.bz2
Correct completely broken os.stat behavior on Windows XP.
After 1a3e8db28d49, Windows XP could not os.stat at all due to raising immediately when GetFinalPathNameByHandle wasn't available (pre-Vista). The proper behavior in that situation is to just not attempt a traversal rather than outright rejecting. This change additionally handles a failed malloc by setting the error code and returning false. Patch by Hirokazu Yamamoto.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index b6f49b8..a93aa6a 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1102,6 +1102,11 @@ get_target_path(HANDLE hdl, wchar_t **target_path)
return FALSE;
buf = (wchar_t *)malloc((buf_size+1)*sizeof(wchar_t));
+ if (!buf) {
+ SetLastError(ERROR_OUTOFMEMORY);
+ return FALSE;
+ }
+
result_length = Py_GetFinalPathNameByHandleW(hdl,
buf, buf_size, VOLUME_NAME_DOS);
@@ -1136,11 +1141,9 @@ win32_xstat_impl(const char *path, struct win32_stat *result,
const char *dot;
if(!check_GetFinalPathNameByHandle()) {
- /* If the OS doesn't have GetFinalPathNameByHandle, return a
- NotImplementedError. */
- PyErr_SetString(PyExc_NotImplementedError,
- "GetFinalPathNameByHandle not available on this platform");
- return -1;
+ /* If the OS doesn't have GetFinalPathNameByHandle, don't
+ traverse reparse point. */
+ traverse = FALSE;
}
hFile = CreateFileA(
@@ -1234,11 +1237,9 @@ win32_xstat_impl_w(const wchar_t *path, struct win32_stat *result,
const wchar_t *dot;
if(!check_GetFinalPathNameByHandle()) {
- /* If the OS doesn't have GetFinalPathNameByHandle, return a
- NotImplementedError. */
- PyErr_SetString(PyExc_NotImplementedError,
- "GetFinalPathNameByHandle not available on this platform");
- return -1;
+ /* If the OS doesn't have GetFinalPathNameByHandle, don't
+ traverse reparse point. */
+ traverse = FALSE;
}
hFile = CreateFileW(