mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 01:59:14 +03:00
Kernel: Make realpath return silently truncated data
For context, see https://github.com/SerenityOS/serenity/discussions/4357
This commit is contained in:
parent
6f607742dd
commit
68416d7293
Notes:
sideshowbarker
2024-07-18 23:10:16 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/68416d72935 Pull-request: https://github.com/SerenityOS/serenity/pull/4965 Reviewed-by: https://github.com/bugaevc Reviewed-by: https://github.com/emanuele6
@ -49,12 +49,12 @@ int Process::sys$realpath(Userspace<const Syscall::SC_realpath_params*> user_par
|
||||
auto& custody = custody_or_error.value();
|
||||
auto absolute_path = custody->absolute_path();
|
||||
|
||||
if (absolute_path.length() + 1 > params.buffer.size)
|
||||
return -ENAMETOOLONG;
|
||||
|
||||
if (!copy_to_user(params.buffer.data, absolute_path.characters(), absolute_path.length() + 1))
|
||||
size_t ideal_size = absolute_path.length() + 1;
|
||||
auto size_to_copy = min(ideal_size, params.buffer.size);
|
||||
if (!copy_to_user(params.buffer.data, absolute_path.characters(), size_to_copy))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
// Note: we return the whole size here, not the copied size.
|
||||
return ideal_size;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user