From 46c9b1d81c22c6840733e821bc0859dda1d65e7d Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Mon, 26 Jul 2021 03:42:16 -0700 Subject: Kernel+LibC: Use argument for TIOCGPGRP ioctl value In preparation for modifying the Kernel IOCTL API to return KResult instead of int, we need to fix this ioctl to an argument to receive it's return value, instead of using the actual function return value. --- Kernel/TTY/TTY.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Kernel/TTY') diff --git a/Kernel/TTY/TTY.cpp b/Kernel/TTY/TTY.cpp index a58b882b4e..c5a7802133 100644 --- a/Kernel/TTY/TTY.cpp +++ b/Kernel/TTY/TTY.cpp @@ -469,8 +469,13 @@ int TTY::ioctl(FileDescription&, unsigned request, Userspace arg) } #endif switch (request) { - case TIOCGPGRP: - return this->pgid().value(); + case TIOCGPGRP: { + auto user_pgid = static_ptr_cast(arg); + auto pgid = this->pgid().value(); + if (!copy_to_user(user_pgid, &pgid)) + return -EFAULT; + return 0; + } case TIOCSPGRP: { ProcessGroupID pgid = static_cast(arg.ptr()); if (pgid <= 0) -- cgit v1.2.3