diff options
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r-- | Kernel/Process.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 568648401e..9c066baf95 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1953,11 +1953,11 @@ int Process::sys$readlink(const Syscall::SC_readlink_params* user_params) if (contents.is_error()) return contents.error(); - auto link_target = String::copy(contents.value()); - if (link_target.length() > params.buffer.size) - return -ENAMETOOLONG; - copy_to_user(params.buffer.data, link_target.characters(), link_target.length()); - return link_target.length(); + auto& link_target = contents.value(); + auto size_to_copy = min(link_target.size(), params.buffer.size); + copy_to_user(params.buffer.data, link_target.data(), size_to_copy); + // Note: we return the whole size here, not the copied size. + return link_target.size(); } int Process::sys$chdir(const char* user_path, size_t path_length) |