[NTOS:KD] Fix buffer overflow for the signon in KdPortInitializeEx.

The built string can be:
°°Kernel Debugger: Serial port found: COM1 (Port 0x000003F8) BaudRate 115200°°°°
(with ° representing the \r and \n in the message)
and you can verify that this is more than 80 characters in total.
This commit is contained in:
Hermès Bélusca-Maïto
2023-04-04 03:03:42 +02:00
parent 641c89d834
commit dfc2cc4e42

View File

@@ -106,15 +106,22 @@ KdPortInitializeEx(
else
{
#ifndef NDEBUG
CHAR buffer[80];
int Length;
CHAR Buffer[82];
/* Print message to blue screen */
sprintf(buffer,
"\r\nKernel Debugger: Serial port found: COM%ld (Port 0x%p) BaudRate %ld\r\n\r\n",
ComPortNumber,
PortInformation->Address,
PortInformation->BaudRate);
HalDisplayString(buffer);
Length = snprintf(Buffer, sizeof(Buffer),
"\r\nKernel Debugger: Serial port found: COM%ld (Port 0x%p) BaudRate %ld\r\n\r\n",
ComPortNumber,
PortInformation->Address,
PortInformation->BaudRate);
if (Length == -1)
{
/* Terminate it if we went over-board */
Buffer[sizeof(Buffer) - 1] = ANSI_NULL;
}
HalDisplayString(Buffer);
#endif /* NDEBUG */
#if 0