mirror of
https://github.com/python/cpython.git
synced 2025-07-25 04:04:13 +00:00
Issue #13772: In os.symlink() under Windows, do not try to guess the link
target's type (file or directory). The detection was buggy and made the call non-atomic (therefore prone to race conditions).
This commit is contained in:
commit
91ecea24f5
4 changed files with 14 additions and 19 deletions
|
@ -6551,7 +6551,6 @@ win_symlink(PyObject *self, PyObject *args, PyObject *kwargs)
|
|||
wchar_t *wsrc, *wdest;
|
||||
int target_is_directory = 0;
|
||||
DWORD res;
|
||||
WIN32_FILE_ATTRIBUTE_DATA src_info;
|
||||
|
||||
if (!check_CreateSymbolicLinkW())
|
||||
{
|
||||
|
@ -6581,16 +6580,6 @@ win_symlink(PyObject *self, PyObject *args, PyObject *kwargs)
|
|||
if (wsrc == NULL)
|
||||
goto error;
|
||||
|
||||
/* if src is a directory, ensure target_is_directory==1 */
|
||||
if(
|
||||
GetFileAttributesExW(
|
||||
wsrc, GetFileExInfoStandard, &src_info
|
||||
))
|
||||
{
|
||||
target_is_directory = target_is_directory ||
|
||||
(src_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
||||
}
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = Py_CreateSymbolicLinkW(wdest, wsrc, target_is_directory);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue