Skip to content

Commit ad4a20b

Browse files
authored
[3.8] bpo-39401: Avoid unsafe DLL load on Windows 7 and earlier (GH-18231) (GH-18234)
https://bugs.python.org/issue39401 Automerge-Triggered-By: @zooba
1 parent 58076df commit ad4a20b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid unsafe load of ``api-ms-win-core-path-l1-1-0.dll`` at startup on Windows 7.

PC/getpathp.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ static void
251251
join(wchar_t *buffer, const wchar_t *stuff)
252252
{
253253
if (_PathCchCombineEx_Initialized == 0) {
254-
HMODULE pathapi = LoadLibraryW(L"api-ms-win-core-path-l1-1-0.dll");
254+
HMODULE pathapi = LoadLibraryExW(L"api-ms-win-core-path-l1-1-0.dll", NULL,
255+
LOAD_LIBRARY_SEARCH_SYSTEM32);
255256
if (pathapi) {
256257
_PathCchCombineEx = (PPathCchCombineEx)GetProcAddress(pathapi, "PathCchCombineEx");
257258
}
@@ -287,7 +288,8 @@ canonicalize(wchar_t *buffer, const wchar_t *path)
287288
}
288289

289290
if (_PathCchCanonicalizeEx_Initialized == 0) {
290-
HMODULE pathapi = LoadLibraryW(L"api-ms-win-core-path-l1-1-0.dll");
291+
HMODULE pathapi = LoadLibraryExW(L"api-ms-win-core-path-l1-1-0.dll", NULL,
292+
LOAD_LIBRARY_SEARCH_SYSTEM32);
291293
if (pathapi) {
292294
_PathCchCanonicalizeEx = (PPathCchCanonicalizeEx)GetProcAddress(pathapi, "PathCchCanonicalizeEx");
293295
}

0 commit comments

Comments
 (0)