[INCLUDE] Safely handle odd & large lengths in ProbeAndCaptureUnicodeString.

This commit is contained in:
Thomas Faber
2019-12-29 15:22:10 +01:00
parent 975e117780
commit 0d26bbf4b5
+12 -1
View File
@@ -180,7 +180,18 @@ ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest,
/* Set it as the buffer */
Dest->Buffer = Buffer;
Dest->MaximumLength = Dest->Length + sizeof(WCHAR);
if (Dest->Length % sizeof(WCHAR))
{
Dest->Length--;
}
if (Dest->Length >= UNICODE_STRING_MAX_BYTES)
{
Dest->MaximumLength = Dest->Length;
}
else
{
Dest->MaximumLength = Dest->Length + sizeof(WCHAR);
}
}
else
{