mirror of
https://github.com/reactos/reactos.git
synced 2024-11-18 21:13:52 +00:00
[0.4.7][SDK:RTL] RtlpCallQueryRegistryRoutine(): Correctly set SpareData and SpareLength (#5466)
ports back:
0.4.15-dev-6640-g 02883d1c16
SpareData and SpareLength need to be calculated correctly, as they are used
later in that function as well.
This allows to not overwrite Source UString when writing to Destination UString.
Fixes the problem described in the following JIRA issue, where services could
not start in 2nd-stage-bootcd-setup when installing ReactOS in a very-long-named directory.
CORE-18988
This commit is contained in:
parent
3f33517d3f
commit
89f60aba16
1 changed files with 28 additions and 28 deletions
|
@ -188,36 +188,36 @@ RtlpCallQueryRegistryRoutine(IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Check if we have length */
|
||||
if (KeyValueInfo->DataLength)
|
||||
{
|
||||
/* Increase the spare data */
|
||||
SpareData += KeyValueInfo->DataOffset +
|
||||
KeyValueInfo->DataLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise, the spare data only has the name data */
|
||||
SpareData += FIELD_OFFSET(KEY_VALUE_FULL_INFORMATION, Name) +
|
||||
KeyValueInfo->NameLength;
|
||||
}
|
||||
|
||||
/* Align the pointer and get new size of spare data */
|
||||
SpareData = (PVOID)(((ULONG_PTR)SpareData + 7) & ~7);
|
||||
SpareLength = DataEnd - SpareData;
|
||||
|
||||
/* Check if we have space to copy the data */
|
||||
RequiredLength = KeyValueInfo->NameLength + sizeof(UNICODE_NULL);
|
||||
if ((SpareData > DataEnd) || (SpareLength < RequiredLength))
|
||||
{
|
||||
/* Fail and return the missing length */
|
||||
*InfoSize = (ULONG)(SpareData - (PCHAR)KeyValueInfo) + RequiredLength;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
/* Check if this isn't a direct return */
|
||||
if (!(QueryTable->Flags & RTL_QUERY_REGISTRY_DIRECT))
|
||||
{
|
||||
/* Check if we have length */
|
||||
if (KeyValueInfo->DataLength)
|
||||
{
|
||||
/* Increase the spare data */
|
||||
SpareData += KeyValueInfo->DataOffset +
|
||||
KeyValueInfo->DataLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise, the spare data only has the name data */
|
||||
SpareData += FIELD_OFFSET(KEY_VALUE_FULL_INFORMATION, Name) +
|
||||
KeyValueInfo->NameLength;
|
||||
}
|
||||
|
||||
/* Align the pointer and get new size of spare data */
|
||||
SpareData = (PVOID)(((ULONG_PTR)SpareData + 7) & ~7);
|
||||
SpareLength = DataEnd - SpareData;
|
||||
|
||||
/* Check if we have space to copy the data */
|
||||
RequiredLength = KeyValueInfo->NameLength + sizeof(UNICODE_NULL);
|
||||
if ((SpareData > DataEnd) || (SpareLength < RequiredLength))
|
||||
{
|
||||
/* Fail and return the missing length */
|
||||
*InfoSize = (ULONG)(SpareData - (PCHAR)KeyValueInfo) + RequiredLength;
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
/* Copy the data and null-terminate it */
|
||||
Name = (PWCHAR)SpareData;
|
||||
RtlCopyMemory(Name, KeyValueInfo->Name, KeyValueInfo->NameLength);
|
||||
|
@ -322,7 +322,7 @@ RtlpCallQueryRegistryRoutine(IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
|
|||
RtlInitEmptyUnicodeString(&Source, Data, (USHORT)Length);
|
||||
Source.Length = Source.MaximumLength - sizeof(UNICODE_NULL);
|
||||
|
||||
/* Setup the desination string */
|
||||
/* Setup the destination string */
|
||||
RtlInitEmptyUnicodeString(&Destination, (PWCHAR)SpareData, 0);
|
||||
|
||||
/* Check if we're out of space */
|
||||
|
|
Loading…
Reference in a new issue