[NTOS:PNP] Correctly respect data size in PnpRegSzToString. CORE-15766

Spotted by Vadim Galyant.
This commit is contained in:
Thomas Faber 2019-02-20 12:21:03 +01:00
parent c83d7ba185
commit cf40421041
No known key found for this signature in database
GPG key ID: 076E7C3D44720826

View file

@ -175,11 +175,20 @@ PnpRegSzToString(IN PWCHAR RegSzData,
PWCHAR p, pp;
/* Find the end */
pp = RegSzData + RegSzLength;
for (p = RegSzData; p < pp; p++) if (!*p) break;
pp = RegSzData + RegSzLength / sizeof(WCHAR);
for (p = RegSzData; p < pp; p++)
{
if (!*p)
{
break;
}
}
/* Return it */
if (StringLength) *StringLength = (USHORT)(p - RegSzData) * sizeof(WCHAR);
/* Return the length. Truncation can happen but is of no consequence. */
if (StringLength)
{
*StringLength = (USHORT)(p - RegSzData) * sizeof(WCHAR);
}
return TRUE;
}