From 4c42d1e35a223443dd089435df36355a3460c95d Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Thu, 11 Feb 2021 19:15:33 +0100 Subject: [PATCH] Kernel: Do not try to print the string that cannot be read What a silly bug :^) Found by fuzz-syscalls. Can be reproduced by running this in the Shell: $ syscall set_thread_name 14 14 14 --- Kernel/StdLib.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp index 266f6811230..34e8375bb93 100644 --- a/Kernel/StdLib.cpp +++ b/Kernel/StdLib.cpp @@ -42,7 +42,7 @@ String copy_string_from_user(const char* user_str, size_t user_str_size) void* fault_at; ssize_t length = Kernel::safe_strnlen(user_str, user_str_size, fault_at); if (length < 0) { - klog() << "copy_string_from_user(" << user_str << ", " << user_str_size << ") failed at " << VirtualAddress(fault_at) << " (strnlen)"; + klog() << "copy_string_from_user(" << static_cast(user_str) << ", " << user_str_size << ") failed at " << VirtualAddress(fault_at) << " (strnlen)"; return {}; } if (length == 0) @@ -51,7 +51,7 @@ String copy_string_from_user(const char* user_str, size_t user_str_size) char* buffer; auto copied_string = StringImpl::create_uninitialized((size_t)length, buffer); if (!Kernel::safe_memcpy(buffer, user_str, (size_t)length, fault_at)) { - klog() << "copy_string_from_user(" << user_str << ", " << user_str_size << ") failed at " << VirtualAddress(fault_at) << " (memcpy)"; + klog() << "copy_string_from_user(" << static_cast(user_str) << ", " << user_str_size << ") failed at " << VirtualAddress(fault_at) << " (memcpy)"; return {}; } return copied_string;