Module: wine Branch: master Commit: ccd9008d8d0a33769d8b328d5bc6775f940ef0bd URL: https://source.winehq.org/git/wine.git/?a=commit;h=ccd9008d8d0a33769d8b328d5...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Aug 10 16:42:09 2021 +0200
ntdll: Don't try to load .so dlls for a different machine.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/unix/loader.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 55fc73d2d06..5f1cbda51a9 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1286,12 +1286,14 @@ static NTSTATUS open_builtin_pe_file( const char *name, OBJECT_ATTRIBUTES *attr, * open_builtin_so_file */ static NTSTATUS open_builtin_so_file( const char *name, OBJECT_ATTRIBUTES *attr, void **module, - SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native ) + SECTION_IMAGE_INFORMATION *image_info, + WORD machine, BOOL prefer_native ) { NTSTATUS status; int fd;
*module = NULL; + if (machine != current_machine) return STATUS_DLL_NOT_FOUND; if ((fd = open( name, O_RDONLY )) == -1) return STATUS_DLL_NOT_FOUND;
if (check_library_arch( fd )) @@ -1362,7 +1364,7 @@ static NTSTATUS find_builtin_dll( UNICODE_STRING *nt_name, void **module, SIZE_T status = open_builtin_pe_file( ptr, &attr, module, size_ptr, image_info, machine, prefer_native ); if (status != STATUS_DLL_NOT_FOUND) goto done; strcpy( file + pos + len + 1, ".so" ); - status = open_builtin_so_file( ptr, &attr, module, image_info, prefer_native ); + status = open_builtin_so_file( ptr, &attr, module, image_info, machine, prefer_native ); if (status != STATUS_DLL_NOT_FOUND) goto done;
/* now as a program */ @@ -1376,7 +1378,7 @@ static NTSTATUS find_builtin_dll( UNICODE_STRING *nt_name, void **module, SIZE_T status = open_builtin_pe_file( ptr, &attr, module, size_ptr, image_info, machine, prefer_native ); if (status != STATUS_DLL_NOT_FOUND) goto done; strcpy( file + pos + len + 1, ".so" ); - status = open_builtin_so_file( ptr, &attr, module, image_info, prefer_native ); + status = open_builtin_so_file( ptr, &attr, module, image_info, machine, prefer_native ); if (status != STATUS_DLL_NOT_FOUND) goto done; }
@@ -1393,11 +1395,10 @@ static NTSTATUS find_builtin_dll( UNICODE_STRING *nt_name, void **module, SIZE_T ptr = prepend( ptr, dll_paths[i], strlen(dll_paths[i]) ); if (status != STATUS_DLL_NOT_FOUND) goto done; strcpy( file + pos + len + 1, ".so" ); - status = open_builtin_so_file( ptr, &attr, module, image_info, prefer_native ); + status = open_builtin_so_file( ptr, &attr, module, image_info, machine, prefer_native ); if (status != STATUS_DLL_NOT_FOUND) goto done; file[pos + len + 1] = 0; ptr = prepend( file + pos, dll_paths[i], strlen(dll_paths[i]) ); - if (status != STATUS_DLL_NOT_FOUND) goto done; status = open_builtin_pe_file( ptr, &attr, module, size_ptr, image_info, machine, prefer_native ); if (status == STATUS_IMAGE_MACHINE_TYPE_MISMATCH) { @@ -1406,7 +1407,7 @@ static NTSTATUS find_builtin_dll( UNICODE_STRING *nt_name, void **module, SIZE_T } if (status != STATUS_DLL_NOT_FOUND) goto done; strcpy( file + pos + len + 1, ".so" ); - status = open_builtin_so_file( ptr, &attr, module, image_info, prefer_native ); + status = open_builtin_so_file( ptr, &attr, module, image_info, machine, prefer_native ); if (status == STATUS_IMAGE_MACHINE_TYPE_MISMATCH) found_image = TRUE; else if (status != STATUS_DLL_NOT_FOUND) goto done; } @@ -1777,7 +1778,7 @@ static void load_ntdll(void) if (status == STATUS_DLL_NOT_FOUND) { sprintf( name, "%s/ntdll.dll.so", ntdll_dir ); - status = open_builtin_so_file( name, &attr, &module, &info, FALSE ); + status = open_builtin_so_file( name, &attr, &module, &info, current_machine, FALSE ); } if (status == STATUS_IMAGE_NOT_AT_BASE) relocate_ntdll( module ); else if (status) fatal_error( "failed to load %s error %x\n", name, status );