From b4926e272404252058869d6b4e297033b8b39c6a Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Sun, 15 Oct 2023 12:59:13 -0500 Subject: [PATCH] advapi32: Respect object type in GetSecurityInfo(). Do not try to treat types which are not kernel handles as kernel handles. --- dlls/advapi32/security.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c index d13fd65af78..8dfb6548588 100644 --- a/dlls/advapi32/security.c +++ b/dlls/advapi32/security.c @@ -1497,6 +1497,10 @@ DWORD WINAPI GetSecurityInfo( HANDLE handle, SE_OBJECT_TYPE type, SECURITY_INFOR NTSTATUS status; ULONG size; BOOL present, defaulted; + HKEY key = NULL; + + if (!handle) + return ERROR_INVALID_HANDLE; /* A NULL descriptor is allowed if any one of the other pointers is not NULL */ if (!(ppsidOwner||ppsidGroup||ppDacl||ppSacl||ppSecurityDescriptor)) return ERROR_INVALID_PARAMETER; @@ -1509,8 +1513,9 @@ DWORD WINAPI GetSecurityInfo( HANDLE handle, SE_OBJECT_TYPE type, SECURITY_INFOR || ((SecurityInfo & SACL_SECURITY_INFORMATION) && !ppSacl) )) return ERROR_INVALID_PARAMETER; - if (type == SE_SERVICE) + switch (type) { + case SE_SERVICE: if (!QueryServiceObjectSecurity( handle, SecurityInfo, NULL, 0, &size ) && GetLastError() != ERROR_INSUFFICIENT_BUFFER) return GetLastError(); @@ -1522,11 +1527,12 @@ DWORD WINAPI GetSecurityInfo( HANDLE handle, SE_OBJECT_TYPE type, SECURITY_INFOR LocalFree(sd); return GetLastError(); } - } - else - { - HKEY key = NULL; + break; + case SE_KERNEL_OBJECT: + case SE_FILE_OBJECT: + case SE_WMIGUID_OBJECT: + case SE_REGISTRY_KEY: if (type == SE_REGISTRY_KEY && (HandleToUlong(handle) >= HandleToUlong(HKEY_SPECIAL_ROOT_FIRST)) && (HandleToUlong(handle) <= HandleToUlong(HKEY_SPECIAL_ROOT_LAST))) { @@ -1562,6 +1568,11 @@ DWORD WINAPI GetSecurityInfo( HANDLE handle, SE_OBJECT_TYPE type, SECURITY_INFOR return RtlNtStatusToDosError( status ); } RegCloseKey( key ); + break; + + default: + FIXME("unimplemented type %u\n", type); + return ERROR_CALL_NOT_IMPLEMENTED; } if (ppsidOwner) -- 2.11.4.GIT