mirror of
https://github.com/reactos/reactos.git
synced 2024-07-04 19:54:58 +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;
|
PWCHAR TargetBuffer, CurrentNameW;
|
||||||
PUCHAR CurrentName;
|
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;
|
NameLength = 0;
|
||||||
MyKcb = Kcb;
|
MyKcb = Kcb;
|
||||||
|
|
||||||
|
@ -906,11 +906,16 @@ CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
|
||||||
{
|
{
|
||||||
/* Add length of the name */
|
/* Add length of the name */
|
||||||
if (!MyKcb->NameBlock->Compressed)
|
if (!MyKcb->NameBlock->Compressed)
|
||||||
|
{
|
||||||
NameLength += MyKcb->NameBlock->NameLength;
|
NameLength += MyKcb->NameBlock->NameLength;
|
||||||
|
}
|
||||||
else
|
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);
|
NameLength += sizeof(WCHAR);
|
||||||
|
|
||||||
/* Go to the parent KCB */
|
/* Go to the parent KCB */
|
||||||
|
@ -918,10 +923,13 @@ CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate the unicode string now */
|
/* 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;
|
if (!KeyName) return NULL;
|
||||||
|
|
||||||
|
/* Set it up */
|
||||||
KeyName->Buffer = (PWSTR)(KeyName + 1);
|
KeyName->Buffer = (PWSTR)(KeyName + 1);
|
||||||
KeyName->Length = NameLength;
|
KeyName->Length = NameLength;
|
||||||
KeyName->MaximumLength = NameLength;
|
KeyName->MaximumLength = NameLength;
|
||||||
|
@ -932,7 +940,7 @@ CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
|
||||||
|
|
||||||
while (MyKcb)
|
while (MyKcb)
|
||||||
{
|
{
|
||||||
/* Sanity checks for deleted keys */
|
/* Sanity checks for deleted and fake keys */
|
||||||
if ((!MyKcb->KeyCell && !MyKcb->Delete) ||
|
if ((!MyKcb->KeyCell && !MyKcb->Delete) ||
|
||||||
!MyKcb->KeyHive ||
|
!MyKcb->KeyHive ||
|
||||||
MyKcb->ExtFlags & CM_KCB_KEY_NON_EXIST)
|
MyKcb->ExtFlags & CM_KCB_KEY_NON_EXIST)
|
||||||
|
|
|
@ -159,7 +159,7 @@ CmpQueryKeyName(IN PVOID ObjectBody,
|
||||||
(Length < (*ReturnLength - sizeof(OBJECT_NAME_INFORMATION))))
|
(Length < (*ReturnLength - sizeof(OBJECT_NAME_INFORMATION))))
|
||||||
{
|
{
|
||||||
/* Free the buffer allocated by CmpConstructName */
|
/* Free the buffer allocated by CmpConstructName */
|
||||||
ExFreePool(KeyName->Buffer);
|
ExFreePool(KeyName);
|
||||||
|
|
||||||
/* Return buffer length failure */
|
/* Return buffer length failure */
|
||||||
return STATUS_INFO_LENGTH_MISMATCH;
|
return STATUS_INFO_LENGTH_MISMATCH;
|
||||||
|
@ -174,7 +174,9 @@ CmpQueryKeyName(IN PVOID ObjectBody,
|
||||||
ObjectNameInfo->Name.Length = KeyName->Length;
|
ObjectNameInfo->Name.Length = KeyName->Length;
|
||||||
|
|
||||||
/* Copy string content*/
|
/* Copy string content*/
|
||||||
RtlCopyMemory(ObjectNameInfo->Name.Buffer, KeyName->Buffer, *ReturnLength);
|
RtlCopyMemory(ObjectNameInfo->Name.Buffer,
|
||||||
|
KeyName->Buffer,
|
||||||
|
*ReturnLength);
|
||||||
}
|
}
|
||||||
_SEH_HANDLE
|
_SEH_HANDLE
|
||||||
{
|
{
|
||||||
|
@ -186,6 +188,7 @@ CmpQueryKeyName(IN PVOID ObjectBody,
|
||||||
/* Free the buffer allocated by CmpConstructName */
|
/* Free the buffer allocated by CmpConstructName */
|
||||||
ExFreePool(KeyName);
|
ExFreePool(KeyName);
|
||||||
|
|
||||||
|
/* Return status */
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue