diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-02-09 12:59:40 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2022-02-09 14:50:19 -0500 |
commit | f1a193b2c7375795487e212cc022f7a3c066634c (patch) | |
tree | 4fddfc577019cfde0ac50cbca18ffb592326a2ee | |
parent | 66036e637ea2b4dd090e1721c6517d8014ed66b1 (diff) | |
download | haskell-wip/T21059.tar.gz |
linker/PEi386: Make addLibrarySearchPath long-path awarewip/T21059
Previously `addLibrarySearchPath` failed to normalise the added path to
UNC form before passing it to `AddDllDirectory`. Consequently, the call
was subject to the MAX_PATH restriction, leading to the failure of
`test-defaulting-plugin-fail`, among others. Happily, this also nicely
simplifies the implementation.
Closes #21059.
-rw-r--r-- | rts/linker/PEi386.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c index e46949d9ea..684b02ac5b 100644 --- a/rts/linker/PEi386.c +++ b/rts/linker/PEi386.c @@ -767,21 +767,9 @@ pathchar* findSystemLibrary_PEi386( pathchar* dll_name ) HsPtr addLibrarySearchPath_PEi386(pathchar* dll_path) { - const unsigned int init_buf_size = 4096; - int bufsize = init_buf_size; - - // Make sure the path is an absolute path - WCHAR* abs_path = stgMallocBytes(sizeof(WCHAR) * init_buf_size, "addLibrarySearchPath_PEi386(1)"); - DWORD wResult = GetFullPathNameW(dll_path, bufsize, abs_path, NULL); - if (!wResult){ - IF_DEBUG(linker, debugBelch("addLibrarySearchPath[GetFullPathNameW]: %" PATH_FMT " (Win32 error %lu)", dll_path, GetLastError())); - } - else if (wResult > init_buf_size) { - abs_path = realloc(abs_path, sizeof(WCHAR) * wResult); - if (!GetFullPathNameW(dll_path, bufsize, abs_path, NULL)) { - IF_DEBUG(linker, debugBelch("addLibrarySearchPath[GetFullPathNameW]: %" PATH_FMT " (Win32 error %lu)", dll_path, GetLastError())); - } - } + // Make sure the path is an absolute path in UNC-style to ensure that we + // aren't subject to the MAX_PATH restriction. See #21059. + wchar_t *abs_path = __rts_create_device_name(dll_path); HsPtr result = AddDllDirectory(abs_path); if (!result) { |