1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:38:11 +00:00

Kernel/Syscalls: Use copy_n_to_user when applicable

copy_to_user() with bytes as the last argument could be changed to using
copy_n_to_user() with a count.
This commit is contained in:
Pankaj Raghav 2023-03-24 09:59:28 +01:00 committed by Andreas Kling
parent f32fde6152
commit d0ac24ddbf
5 changed files with 10 additions and 9 deletions

View file

@ -428,7 +428,7 @@ ErrorOr<FlatPtr> Process::sys$socketpair(Userspace<Syscall::SC_socketpair_params
setup_socket_fd(fds, allocated_fds[0], pair.description0, params.type);
setup_socket_fd(fds, allocated_fds[1], pair.description1, params.type);
if (copy_to_user(params.sv, allocated_fds, sizeof(allocated_fds)).is_error()) {
if (copy_n_to_user(params.sv, allocated_fds, 2).is_error()) {
// Avoid leaking both file descriptors on error.
fds[allocated_fds[0]] = {};
fds[allocated_fds[1]] = {};