https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0d26bbf4b5c63ff58bd0e2...
commit 0d26bbf4b5c63ff58bd0e229753b6ff185e128cb Author: Thomas Faber thomas.faber@reactos.org AuthorDate: Sun Dec 29 15:10:37 2019 +0100 Commit: Thomas Faber thomas.faber@reactos.org CommitDate: Sun Dec 29 15:22:10 2019 +0100
[INCLUDE] Safely handle odd & large lengths in ProbeAndCaptureUnicodeString. --- sdk/include/reactos/probe.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/sdk/include/reactos/probe.h b/sdk/include/reactos/probe.h index 0aac83f065f..16ee4bd6e38 100644 --- a/sdk/include/reactos/probe.h +++ b/sdk/include/reactos/probe.h @@ -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 {