summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-02-09 12:59:40 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-02-10 04:36:46 -0500
commit2a6f2681ad53899869473343e845bee189a809c3 (patch)
tree099b1ad62e702c4adc7730944b74a2e1f5ccae7e
parent1d3ed1687f8eb5023338499f5f548a5b39074349 (diff)
downloadhaskell-2a6f2681ad53899869473343e845bee189a809c3.tar.gz
linker/PEi386: Make addLibrarySearchPath long-path aware
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.c18
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) {