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

This commit is contained in:
Thomas Faber 2019-12-29 15:10:37 +01:00
parent 975e117780
commit 0d26bbf4b5
No known key found for this signature in database
GPG key ID: 076E7C3D44720826

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
{