mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:47:44 +00:00
AK+Kernel: Introduce StdLib function to copy FixedStringBuffer to user
This new Kernel StdLib function will be used to copy contents of a FixedStringBuffer with a null character to a user process. The first user of this new function is the prctl option of PR_GET_PROCESS_NAME which would copy a process name including a null character to a user provided buffer.
This commit is contained in:
parent
6cb88e224e
commit
72231b405a
3 changed files with 19 additions and 5 deletions
|
@ -66,10 +66,8 @@ ErrorOr<FlatPtr> Process::sys$prctl(int option, FlatPtr arg1, FlatPtr arg2)
|
|||
Userspace<char*> buffer = arg1;
|
||||
size_t buffer_size = static_cast<size_t>(arg2);
|
||||
TRY(m_name.with([&buffer, buffer_size](auto& name) -> ErrorOr<void> {
|
||||
auto view = name.representable_view();
|
||||
if (view.length() + 1 > buffer_size)
|
||||
return ENAMETOOLONG;
|
||||
return copy_to_user(buffer, view.characters_without_null_termination(), view.length() + 1);
|
||||
VERIFY(!name.representable_view().is_null());
|
||||
return copy_fixed_string_buffer_including_null_char_to_user(buffer, buffer_size, name);
|
||||
}));
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue