mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:47:34 +00: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
1 changed files with 5 additions and 5 deletions
|
@ -49,12 +49,12 @@ int Process::sys$realpath(Userspace<const Syscall::SC_realpath_params*> user_par
|
||||||
auto& custody = custody_or_error.value();
|
auto& custody = custody_or_error.value();
|
||||||
auto absolute_path = custody->absolute_path();
|
auto absolute_path = custody->absolute_path();
|
||||||
|
|
||||||
if (absolute_path.length() + 1 > params.buffer.size)
|
size_t ideal_size = absolute_path.length() + 1;
|
||||||
return -ENAMETOOLONG;
|
auto size_to_copy = min(ideal_size, params.buffer.size);
|
||||||
|
if (!copy_to_user(params.buffer.data, absolute_path.characters(), size_to_copy))
|
||||||
if (!copy_to_user(params.buffer.data, absolute_path.characters(), absolute_path.length() + 1))
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return 0;
|
// Note: we return the whole size here, not the copied size.
|
||||||
|
return ideal_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue