mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +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:
parent
4a2dcea685
commit
47a58c51c6
Notes:
sideshowbarker
2024-07-17 11:22:38 +09:00
Author: https://github.com/FireFox317
Commit: 47a58c51c6
Pull-request: https://github.com/SerenityOS/serenity/pull/13885
Reviewed-by: https://github.com/linusg ✅
3 changed files with 10 additions and 11 deletions
|
@ -15,9 +15,8 @@ namespace Prekernel {
|
|||
{
|
||||
auto& uart = Prekernel::UART::the();
|
||||
|
||||
if (msg) {
|
||||
uart.print_str(msg);
|
||||
}
|
||||
while (*msg)
|
||||
uart.send(*msg++);
|
||||
|
||||
Prekernel::halt();
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue