Author: fireball Date: Thu Aug 28 10:37:57 2008 New Revision: 35732
URL: http://svn.reactos.org/svn/reactos?rev=35732&view=rev Log: - 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.
Modified: trunk/reactos/ntoskrnl/config/cmkcbncb.c trunk/reactos/ntoskrnl/config/cmsysini.c
Modified: trunk/reactos/ntoskrnl/config/cmkcbncb.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmkcbncb.c?... ============================================================================== --- trunk/reactos/ntoskrnl/config/cmkcbncb.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/config/cmkcbncb.c [iso-8859-1] Thu Aug 28 10:37:57 2008 @@ -898,7 +898,7 @@ 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 @@ { /* Add length of the name */ if (!MyKcb->NameBlock->Compressed) + { NameLength += MyKcb->NameBlock->NameLength; + } else - NameLength += MyKcb->NameBlock->NameLength * sizeof(WCHAR); - - /* Sum up the separator also */ + { + NameLength += CmpCompressedNameSize(MyKcb->NameBlock->Name, + MyKcb->NameBlock->NameLength); + } + + /* Sum up the separator too */ NameLength += sizeof(WCHAR);
/* Go to the parent KCB */ @@ -918,10 +923,13 @@ }
/* 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 @@
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)
Modified: trunk/reactos/ntoskrnl/config/cmsysini.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c?... ============================================================================== --- trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] Thu Aug 28 10:37:57 2008 @@ -159,7 +159,7 @@ (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 @@ 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 @@ /* Free the buffer allocated by CmpConstructName */ ExFreePool(KeyName);
+ /* Return status */ return Status; }