mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
Kernel: Remove copy_string_from_user() as it's no longer used
This commit is contained in:
parent
0f6f863382
commit
96d5d017b7
3 changed files with 0 additions and 36 deletions
|
@ -13,35 +13,6 @@
|
|||
#include <Kernel/Memory/MemoryManager.h>
|
||||
#include <Kernel/StdLib.h>
|
||||
|
||||
String copy_string_from_user(const char* user_str, size_t user_str_size)
|
||||
{
|
||||
bool is_user = Kernel::Memory::is_user_range(VirtualAddress(user_str), user_str_size);
|
||||
if (!is_user)
|
||||
return {};
|
||||
Kernel::SmapDisabler disabler;
|
||||
void* fault_at;
|
||||
ssize_t length = Kernel::safe_strnlen(user_str, user_str_size, fault_at);
|
||||
if (length < 0) {
|
||||
dbgln("copy_string_from_user({:p}, {}) failed at {} (strnlen)", static_cast<const void*>(user_str), user_str_size, VirtualAddress { fault_at });
|
||||
return {};
|
||||
}
|
||||
if (length == 0)
|
||||
return String::empty();
|
||||
|
||||
char* buffer;
|
||||
auto copied_string = StringImpl::create_uninitialized((size_t)length, buffer);
|
||||
if (!Kernel::safe_memcpy(buffer, user_str, (size_t)length, fault_at)) {
|
||||
dbgln("copy_string_from_user({:p}, {}) failed at {} (memcpy)", static_cast<const void*>(user_str), user_str_size, VirtualAddress { fault_at });
|
||||
return {};
|
||||
}
|
||||
return copied_string;
|
||||
}
|
||||
|
||||
String copy_string_from_user(Userspace<const char*> user_str, size_t user_str_size)
|
||||
{
|
||||
return copy_string_from_user(user_str.unsafe_userspace_ptr(), user_str_size);
|
||||
}
|
||||
|
||||
Kernel::KResultOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(Userspace<const char*> user_str, size_t user_str_size)
|
||||
{
|
||||
bool is_user = Kernel::Memory::is_user_range(VirtualAddress(user_str), user_str_size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue