1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:28:11 +00:00

Kernel: Modify UART::print_str() to also take into account the length

Previously in the aarch64 Kernel, this would cause dbgln() to actually
print more characters of the next string in memory, because strings in
the Kernel are not zero terminated by default. Prevent this by using the
passed in length of the string.
This commit is contained in:
Timon Kruiper 2022-05-02 20:03:06 +02:00 committed by Linus Groh
parent 4a2dcea685
commit 47a58c51c6
3 changed files with 10 additions and 11 deletions

View file

@ -15,9 +15,8 @@ namespace Prekernel {
{
auto& uart = Prekernel::UART::the();
if (msg) {
uart.print_str(msg);
}
while (*msg)
uart.send(*msg++);
Prekernel::halt();
}

View file

@ -22,9 +22,9 @@ public:
void send(u32 c);
u32 receive();
void print_str(char const* s)
void print_str(char const* s, size_t length)
{
while (*s)
for (size_t i = 0; i < length; ++i)
send(*s++);
}
void print_num(u64 n)

View file

@ -9,29 +9,29 @@
// FIXME: Merge the code in this file with Kernel/kprintf.cpp once the proper abstractions are in place.
void kernelputstr(char const* characters, size_t)
void kernelputstr(char const* characters, size_t length)
{
if (!characters)
return;
auto& uart = Prekernel::UART::the();
uart.print_str(characters);
uart.print_str(characters, length);
}
void kernelcriticalputstr(char const* characters, size_t)
void kernelcriticalputstr(char const* characters, size_t length)
{
if (!characters)
return;
auto& uart = Prekernel::UART::the();
uart.print_str(characters);
uart.print_str(characters, length);
}
void kernelearlyputstr(char const* characters, size_t)
void kernelearlyputstr(char const* characters, size_t length)
{
if (!characters)
return;
auto& uart = Prekernel::UART::the();
uart.print_str(characters);
uart.print_str(characters, length);
}