Description
Our kernel and drivers sometimes write registry string values without properly null-terminating them.
This can be found by e.g. adding a check like this to CmSetValueKey:
if (Type == REG_SZ)
|
{
|
ASSERT(DataLength >= sizeof(WCHAR) && ((PWCHAR)Data)[DataLength / sizeof(WCHAR) - 1] == UNICODE_NULL);
|
}
|
else if (Type == REG_MULTI_SZ)
|
{
|
ASSERT(DataLength >= sizeof(WCHAR) && ((PWCHAR)Data)[DataLength / sizeof(WCHAR) - 1] == UNICODE_NULL);
|
ASSERT(DataLength >= 2*sizeof(WCHAR) && ((PWCHAR)Data)[DataLength / sizeof(WCHAR) - 2] == UNICODE_NULL);
|
}
|