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:
parent
99195e3c36
commit
18da5c3042
@ -21,6 +21,8 @@ static uint32 sBufferPosition;
|
|||||||
static void
|
static void
|
||||||
syslog_write(const char* buffer, size_t length)
|
syslog_write(const char* buffer, size_t length)
|
||||||
{
|
{
|
||||||
|
if (sBufferPosition + length > sizeof(sBuffer))
|
||||||
|
return;
|
||||||
memcpy(sBuffer + sBufferPosition, buffer, length);
|
memcpy(sBuffer + sBufferPosition, buffer, length);
|
||||||
sBufferPosition += length;
|
sBufferPosition += length;
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,11 @@ static char sBuffer[16384];
|
|||||||
static uint32 sBufferPosition;
|
static uint32 sBufferPosition;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
syslog_write(const char* buffer, size_t length)
|
syslog_write(const char* buffer, size_t length)
|
||||||
{
|
{
|
||||||
|
if (sBufferPosition + length > sizeof(sBuffer))
|
||||||
|
return;
|
||||||
memcpy(sBuffer + sBufferPosition, buffer, length);
|
memcpy(sBuffer + sBufferPosition, buffer, length);
|
||||||
sBufferPosition += length;
|
sBufferPosition += length;
|
||||||
}
|
}
|
||||||
@ -41,7 +43,7 @@ panic(const char* format, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
dprintf_args(const char *format, va_list args)
|
dprintf_args(const char *format, va_list args)
|
||||||
{
|
{
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
|
Loading…
Reference in New Issue
Block a user