mirror of
https://github.com/python/cpython.git
synced 2025-12-08 02:08:20 +00:00
gh-86179: Avoid making case-only changes when calculating realpath() during initialization (GH-113077)
This commit is contained in:
parent
6873555955
commit
fd81afc624
1 changed files with 11 additions and 2 deletions
|
|
@ -506,12 +506,17 @@ done:
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
wchar_t resolved[MAXPATHLEN+1];
|
wchar_t resolved[MAXPATHLEN+1];
|
||||||
int len = 0, err;
|
int len = 0, err;
|
||||||
|
Py_ssize_t pathlen;
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
|
|
||||||
wchar_t *path = PyUnicode_AsWideCharString(pathobj, NULL);
|
wchar_t *path = PyUnicode_AsWideCharString(pathobj, &pathlen);
|
||||||
if (!path) {
|
if (!path) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (wcslen(path) != pathlen) {
|
||||||
|
PyErr_SetString(PyExc_ValueError, "path contains embedded nulls");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
hFile = CreateFileW(path, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
hFile = CreateFileW(path, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
||||||
|
|
@ -535,7 +540,11 @@ done:
|
||||||
len -= 4;
|
len -= 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (CompareStringOrdinal(path, (int)pathlen, p, len, TRUE) == CSTR_EQUAL) {
|
||||||
|
result = Py_NewRef(pathobj);
|
||||||
|
} else {
|
||||||
result = PyUnicode_FromWideChar(p, len);
|
result = PyUnicode_FromWideChar(p, len);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
result = Py_NewRef(pathobj);
|
result = Py_NewRef(pathobj);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue