Author: ekohl
Date: Sat Aug 13 16:26:23 2016
New Revision: 72215
URL:
http://svn.reactos.org/svn/reactos?rev=72215&view=rev
Log:
[LSASRV]
- LsapRegQueryKeyInfo: Return the maximum sub key name length too.
- LsarEnumerateAccounts: User the maximum sub key name length to allocate a large enough
buffer instead of using a fixed size one.
- LsarAddAccountRights: Use the proper value size to retrieve the system access
attribute.
Modified:
trunk/reactos/dll/win32/lsasrv/lsarpc.c
trunk/reactos/dll/win32/lsasrv/lsasrv.h
trunk/reactos/dll/win32/lsasrv/registry.c
Modified: trunk/reactos/dll/win32/lsasrv/lsarpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsarpc.c?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] Sat Aug 13 16:26:23 2016
@@ -654,10 +654,11 @@
{
LSAPR_ACCOUNT_ENUM_BUFFER EnumBuffer = {0, NULL};
PLSA_DB_OBJECT PolicyObject = NULL;
- WCHAR AccountKeyName[64];
+ PWSTR AccountKeyBuffer = NULL;
HANDLE AccountsKeyHandle = NULL;
HANDLE AccountKeyHandle;
HANDLE SidKeyHandle;
+ ULONG AccountKeyBufferSize;
ULONG EnumIndex;
ULONG EnumCount;
ULONG RequiredLength;
@@ -693,6 +694,23 @@
if (!NT_SUCCESS(Status))
return Status;
+ Status = LsapRegQueryKeyInfo(AccountsKeyHandle,
+ NULL,
+ &AccountKeyBufferSize,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("LsapRegQueryKeyInfo returned 0x%08lx\n", Status);
+ return Status;
+ }
+
+ AccountKeyBufferSize += sizeof(WCHAR);
+ AccountKeyBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, AccountKeyBufferSize);
+ if (AccountKeyBuffer == NULL)
+ {
+ return STATUS_NO_MEMORY;
+ }
+
EnumIndex = *EnumerationContext;
EnumCount = 0;
RequiredLength = 0;
@@ -701,16 +719,16 @@
{
Status = LsapRegEnumerateSubKey(AccountsKeyHandle,
EnumIndex,
- 64 * sizeof(WCHAR),
- AccountKeyName);
+ AccountKeyBufferSize,
+ AccountKeyBuffer);
if (!NT_SUCCESS(Status))
break;
TRACE("EnumIndex: %lu\n", EnumIndex);
- TRACE("Account key name: %S\n", AccountKeyName);
+ TRACE("Account key name: %S\n", AccountKeyBuffer);
Status = LsapRegOpenKey(AccountsKeyHandle,
- AccountKeyName,
+ AccountKeyBuffer,
KEY_READ,
&AccountKeyHandle);
TRACE("LsapRegOpenKey returned %08lX\n", Status);
@@ -766,16 +784,16 @@
{
Status = LsapRegEnumerateSubKey(AccountsKeyHandle,
EnumIndex,
- 64 * sizeof(WCHAR),
- AccountKeyName);
+ AccountKeyBufferSize,
+ AccountKeyBuffer);
if (!NT_SUCCESS(Status))
break;
TRACE("EnumIndex: %lu\n", EnumIndex);
- TRACE("Account key name: %S\n", AccountKeyName);
+ TRACE("Account key name: %S\n", AccountKeyBuffer);
Status = LsapRegOpenKey(AccountsKeyHandle,
- AccountKeyName,
+ AccountKeyBuffer,
KEY_READ,
&AccountKeyHandle);
TRACE("LsapRegOpenKey returned %08lX\n", Status);
@@ -845,6 +863,9 @@
}
}
+ if (AccountKeyBuffer != NULL)
+ RtlFreeHeap(RtlGetProcessHeap(), 0, AccountKeyBuffer);
+
if (AccountsKeyHandle != NULL)
LsapRegCloseKey(AccountsKeyHandle);
@@ -2520,7 +2541,7 @@
if (ulNewRights > 0)
{
- Size = 0;
+ Size = sizeof(ACCESS_MASK);
/* Get the system access flags, if the attribute exists */
Status = LsapGetObjectAttribute(AccountObject,
Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.h?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] Sat Aug 13 16:26:23 2016
@@ -364,6 +364,7 @@
NTSTATUS
LsapRegQueryKeyInfo(IN HANDLE KeyHandle,
OUT PULONG SubKeyCount,
+ OUT PULONG MaxSubKeyNameLength,
OUT PULONG ValueCount);
NTSTATUS
Modified: trunk/reactos/dll/win32/lsasrv/registry.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/registry.…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/registry.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/registry.c [iso-8859-1] Sat Aug 13 16:26:23 2016
@@ -175,6 +175,7 @@
NTSTATUS
LsapRegQueryKeyInfo(IN HANDLE KeyHandle,
OUT PULONG SubKeyCount,
+ OUT PULONG MaxSubKeyNameLength,
OUT PULONG ValueCount)
{
KEY_FULL_INFORMATION FullInfoBuffer;
@@ -195,6 +196,9 @@
if (SubKeyCount != NULL)
*SubKeyCount = FullInfoBuffer.SubKeys;
+
+ if (MaxSubKeyNameLength != NULL)
+ *MaxSubKeyNameLength = FullInfoBuffer.MaxNameLen;
if (ValueCount != NULL)
*ValueCount = FullInfoBuffer.Values;