mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 22:47:28 +00:00
- Use CmpCompressedNameSize to obtain the compressed name length (I'll convert the other part of the routine to use CmpCopyCompressedName later, instead of assuming the current way of things).
- Fix incorrect freeing of a buffer returned by a call to CmpConstructName (spotted by Stefan Ginsberg). - Changes in a couple of comments for better description, and a couple of 80col exceeders fixed. svn path=/trunk/; revision=35732
This commit is contained in:
parent
aa17a34237
commit
de3ef9b823
|
@ -898,7 +898,7 @@ CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
|
|||
PWCHAR TargetBuffer, CurrentNameW;
|
||||
PUCHAR CurrentName;
|
||||
|
||||
/* Calculate how much size our key name is going to occupy */
|
||||
/* Calculate how much size our key name is going to occupy */
|
||||
NameLength = 0;
|
||||
MyKcb = Kcb;
|
||||
|
||||
|
@ -906,11 +906,16 @@ CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
|
|||
{
|
||||
/* Add length of the name */
|
||||
if (!MyKcb->NameBlock->Compressed)
|
||||
{
|
||||
NameLength += MyKcb->NameBlock->NameLength;
|
||||
}
|
||||
else
|
||||
NameLength += MyKcb->NameBlock->NameLength * sizeof(WCHAR);
|
||||
{
|
||||
NameLength += CmpCompressedNameSize(MyKcb->NameBlock->Name,
|
||||
MyKcb->NameBlock->NameLength);
|
||||
}
|
||||
|
||||
/* Sum up the separator also */
|
||||
/* Sum up the separator too */
|
||||
NameLength += sizeof(WCHAR);
|
||||
|
||||
/* Go to the parent KCB */
|
||||
|
@ -918,10 +923,13 @@ CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
|
|||
}
|
||||
|
||||
/* Allocate the unicode string now */
|
||||
KeyName = ExAllocatePoolWithTag(PagedPool, NameLength + sizeof(UNICODE_STRING), TAG_CM);
|
||||
KeyName = ExAllocatePoolWithTag(PagedPool,
|
||||
NameLength + sizeof(UNICODE_STRING),
|
||||
TAG_CM);
|
||||
|
||||
if (!KeyName) return NULL;
|
||||
|
||||
/* Set it up */
|
||||
KeyName->Buffer = (PWSTR)(KeyName + 1);
|
||||
KeyName->Length = NameLength;
|
||||
KeyName->MaximumLength = NameLength;
|
||||
|
@ -932,7 +940,7 @@ CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
|
|||
|
||||
while (MyKcb)
|
||||
{
|
||||
/* Sanity checks for deleted keys */
|
||||
/* Sanity checks for deleted and fake keys */
|
||||
if ((!MyKcb->KeyCell && !MyKcb->Delete) ||
|
||||
!MyKcb->KeyHive ||
|
||||
MyKcb->ExtFlags & CM_KCB_KEY_NON_EXIST)
|
||||
|
|
|
@ -159,7 +159,7 @@ CmpQueryKeyName(IN PVOID ObjectBody,
|
|||
(Length < (*ReturnLength - sizeof(OBJECT_NAME_INFORMATION))))
|
||||
{
|
||||
/* Free the buffer allocated by CmpConstructName */
|
||||
ExFreePool(KeyName->Buffer);
|
||||
ExFreePool(KeyName);
|
||||
|
||||
/* Return buffer length failure */
|
||||
return STATUS_INFO_LENGTH_MISMATCH;
|
||||
|
@ -174,7 +174,9 @@ CmpQueryKeyName(IN PVOID ObjectBody,
|
|||
ObjectNameInfo->Name.Length = KeyName->Length;
|
||||
|
||||
/* Copy string content*/
|
||||
RtlCopyMemory(ObjectNameInfo->Name.Buffer, KeyName->Buffer, *ReturnLength);
|
||||
RtlCopyMemory(ObjectNameInfo->Name.Buffer,
|
||||
KeyName->Buffer,
|
||||
*ReturnLength);
|
||||
}
|
||||
_SEH_HANDLE
|
||||
{
|
||||
|
@ -186,6 +188,7 @@ CmpQueryKeyName(IN PVOID ObjectBody,
|
|||
/* Free the buffer allocated by CmpConstructName */
|
||||
ExFreePool(KeyName);
|
||||
|
||||
/* Return status */
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue