Bootloader log: check for buffer overflow

We could overflow the in-memory log. The bounds check was there for BIOS
already but was missing in EFI and openfirmware. Could fix some crashes
when there is lots of loging.
This commit is contained in:
PulkoMandy 2020-03-17 21:28:07 +01:00
parent 99195e3c36
commit 18da5c3042
2 changed files with 6 additions and 2 deletions

View File

@ -21,6 +21,8 @@ static uint32 sBufferPosition;
static void
syslog_write(const char* buffer, size_t length)
{
if (sBufferPosition + length > sizeof(sBuffer))
return;
memcpy(sBuffer + sBufferPosition, buffer, length);
sBufferPosition += length;
}

View File

@ -17,9 +17,11 @@ static char sBuffer[16384];
static uint32 sBufferPosition;
static void
static inline void
syslog_write(const char* buffer, size_t length)
{
if (sBufferPosition + length > sizeof(sBuffer))
return;
memcpy(sBuffer + sBufferPosition, buffer, length);
sBufferPosition += length;
}
@ -41,7 +43,7 @@ panic(const char* format, ...)
}
static void
static inline void
dprintf_args(const char *format, va_list args)
{
char buffer[512];