mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
[WIN32K]
Make sure strings returned by internal function RegQueryValue are NULL terminated svn path=/trunk/; revision=51139
This commit is contained in:
parent
547a7d215f
commit
0b986764d4
1 changed files with 6 additions and 3 deletions
|
@ -58,7 +58,7 @@ RegQueryValue(
|
||||||
ULONG cbInfoSize, cbDataSize;
|
ULONG cbInfoSize, cbDataSize;
|
||||||
|
|
||||||
/* Check if the local buffer is sufficient */
|
/* Check if the local buffer is sufficient */
|
||||||
cbInfoSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + *pcbValue;
|
cbInfoSize = FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data) + *pcbValue;
|
||||||
if (cbInfoSize <= sizeof(ajBuffer))
|
if (cbInfoSize <= sizeof(ajBuffer))
|
||||||
{
|
{
|
||||||
pInfo = (PVOID)ajBuffer;
|
pInfo = (PVOID)ajBuffer;
|
||||||
|
@ -89,8 +89,11 @@ RegQueryValue(
|
||||||
/* Did we get the right type */
|
/* Did we get the right type */
|
||||||
if (pInfo->Type == ulType)
|
if (pInfo->Type == ulType)
|
||||||
{
|
{
|
||||||
/* Copy the contents to the caller */
|
/* Copy the contents to the caller. Make sure strings are null terminated */
|
||||||
RtlCopyMemory(pvData, pInfo->Data, min(*pcbValue, cbDataSize));
|
if (ulType == REG_SZ || ulType == REG_MULTI_SZ || ulType == REG_EXPAND_SZ)
|
||||||
|
RtlStringCbCopyNW((LPWSTR)pvData, *pcbValue, (LPWSTR)pInfo->Data, cbDataSize);
|
||||||
|
else
|
||||||
|
RtlCopyMemory(pvData, pInfo->Data, cbDataSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Status = STATUS_OBJECT_TYPE_MISMATCH;
|
Status = STATUS_OBJECT_TYPE_MISMATCH;
|
||||||
|
|
Loading…
Reference in a new issue