Module: wine Branch: master Commit: d76f5b4ab9b3a298529bc6449dca7e47cd7c4c6e URL: https://gitlab.winehq.org/wine/wine/-/commit/d76f5b4ab9b3a298529bc6449dca7e4...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Sep 12 10:00:24 2023 +0200
win32u: Use the correct length for kernel object names in object attributes.
---
dlls/win32u/sysparams.c | 3 ++- dlls/win32u/winstation.c | 3 ++- dlls/winex11.drv/x11drv_main.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index fed309ff3d8..5506abac7c6 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -450,7 +450,8 @@ static HANDLE get_display_device_init_mutex( void )
snprintf( buffer, ARRAY_SIZE(buffer), "\Sessions\%u\BaseNamedObjects\display_device_init", (int)NtCurrentTeb()->Peb->SessionId ); - name.Length = name.MaximumLength = asciiz_to_unicode( bufferW, buffer ); + name.MaximumLength = asciiz_to_unicode( bufferW, buffer ); + name.Length = name.MaximumLength - sizeof(WCHAR);
InitializeObjectAttributes( &attr, &name, OBJ_OPENIF, NULL, NULL ); if (NtCreateMutant( &mutex, MUTEX_ALL_ACCESS, &attr, FALSE ) < 0) return 0; diff --git a/dlls/win32u/winstation.c b/dlls/win32u/winstation.c index 5d1d5254ae1..b187b246941 100644 --- a/dlls/win32u/winstation.c +++ b/dlls/win32u/winstation.c @@ -554,7 +554,8 @@ static HANDLE get_winstations_dir_handle(void)
sprintf( bufferA, "\Sessions\%u\Windows\WindowStations", (int)NtCurrentTeb()->Peb->SessionId ); str.Buffer = buffer; - str.Length = str.MaximumLength = asciiz_to_unicode( buffer, bufferA ) - sizeof(WCHAR); + str.MaximumLength = asciiz_to_unicode( buffer, bufferA ); + str.Length = str.MaximumLength - sizeof(WCHAR); InitializeObjectAttributes( &attr, &str, 0, 0, NULL ); status = NtOpenDirectoryObject( &dir, DIRECTORY_CREATE_OBJECT | DIRECTORY_TRAVERSE, &attr ); return status ? 0 : dir; diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index c4d537d6ada..32a20e0e4f2 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -1008,7 +1008,8 @@ static HANDLE get_display_device_init_mutex(void)
snprintf( buffer, ARRAY_SIZE(buffer), "\Sessions\%u\BaseNamedObjects\display_device_init", (int)NtCurrentTeb()->Peb->SessionId ); - name.Length = name.MaximumLength = asciiz_to_unicode( bufferW, buffer ); + name.MaximumLength = asciiz_to_unicode( bufferW, buffer ); + name.Length = name.MaximumLength - sizeof(WCHAR);
InitializeObjectAttributes( &attr, &name, OBJ_OPENIF, NULL, NULL ); if (NtCreateMutant( &mutex, MUTEX_ALL_ACCESS, &attr, FALSE ) < 0) return 0;