[PATCH 0/2] MR10597: ntdll: Fix unixlib extension position.
Doing it after --pos causes an off by one error and strips one character at the end of the name. It also doesn't need to be conditional if we initialize it before the loop. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10597
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/ntdll/unix/loader.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index b66be2bb06e..b1233afc07c 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1301,7 +1301,7 @@ NTSTATUS load_builtin( struct pe_mapping_info *pe_mapping, USHORT machine, */ NTSTATUS load_unixlib_by_name( const UNICODE_STRING *nt_name, void **handle_ret ) { - unsigned int i, pos, namepos, maxlen = 0; + unsigned int i, pos, maxlen = 0; unsigned int len = nt_name->Length / sizeof(WCHAR); const char *so_dir = get_so_dir( current_machine ); char *ptr = NULL, *file, *ext = NULL; @@ -1309,8 +1309,7 @@ NTSTATUS load_unixlib_by_name( const UNICODE_STRING *nt_name, void **handle_ret if (!len) return STATUS_DLL_NOT_FOUND; - for (i = namepos = 0; i < len; i++) - if (nt_name->Buffer[i] == '/' || nt_name->Buffer[i] == '\\') break; + for (i = 0; i < len; i++) if (nt_name->Buffer[i] == '/' || nt_name->Buffer[i] == '\\') break; if (i < len) /* explicit path */ { @@ -1333,8 +1332,8 @@ NTSTATUS load_unixlib_by_name( const UNICODE_STRING *nt_name, void **handle_ret /* we don't want to depend on the current codepage here */ for (i = 0; i < len; i++) { - if (nt_name->Buffer[namepos + i] > 127) goto done; - file[pos + i] = (char)nt_name->Buffer[namepos + i]; + if (nt_name->Buffer[i] > 127) goto done; + file[pos + i] = (char)nt_name->Buffer[i]; if (file[pos + i] >= 'A' && file[pos + i] <= 'Z') file[pos + i] += 'a' - 'A'; else if (file[pos + i] == '.') ext = file + pos + i; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10597
From: Rémi Bernon <rbernon@codeweavers.com> Doing it after --pos causes an off by one error and strips one character at the end of the name. It also doesn't need to be conditional if we initialize it before the loop. --- dlls/ntdll/unix/loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index b1233afc07c..9d70aa421f0 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1329,6 +1329,7 @@ NTSTATUS load_unixlib_by_name( const UNICODE_STRING *nt_name, void **handle_ret if (!(file = malloc( maxlen ))) return STATUS_NO_MEMORY; pos = maxlen - len - 4; + ext = file + pos + len; /* we don't want to depend on the current codepage here */ for (i = 0; i < len; i++) { @@ -1339,7 +1340,6 @@ NTSTATUS load_unixlib_by_name( const UNICODE_STRING *nt_name, void **handle_ret } file[pos + len] = 0; file[--pos] = '/'; - if (!ext) ext = file + pos + len; if (build_dir) { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10597
participants (2)
-
Rémi Bernon -
Rémi Bernon (@rbernon)