[NTOS:KD] Don't assume null termination in KdpSerialDebugPrint and KdpScreenPrint. CORE-14057 CORE-14103

This commit is contained in:
Thomas Faber 2017-12-12 12:38:45 +01:00
parent a0fe72e218
commit a07b569b25
No known key found for this signature in database
GPG key ID: 076E7C3D44720826

View file

@ -340,7 +340,7 @@ KdpSerialDebugPrint(LPSTR Message,
} }
/* Output the message */ /* Output the message */
while (*pch != 0) while (pch < Message + Length && *pch != '\0')
{ {
if (*pch == '\n') if (*pch == '\n')
{ {
@ -412,7 +412,7 @@ KdpScreenPrint(LPSTR Message,
KIRQL OldIrql; KIRQL OldIrql;
PCHAR pch = (PCHAR) Message; PCHAR pch = (PCHAR) Message;
while (*pch) while (pch < Message + Length && *pch)
{ {
if(*pch == '\b') if(*pch == '\b')
{ {
@ -584,9 +584,8 @@ KdpPrintString(
_SEH2_TRY _SEH2_TRY
{ {
ProbeForRead(UnsafeString, Length, 1); ProbeForRead(UnsafeString, Length, 1);
String = _alloca(Length + 1); String = _alloca(Length);
RtlCopyMemory(String, UnsafeString, Length); RtlCopyMemory(String, UnsafeString, Length);
String[Length] = ANSI_NULL;
} }
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{ {