소스 검색

Kernel: Use already computed nfds_checked value when copying from user mode.

- We've already computed the number of fds * sizeof(pollfd), so use it
  instead of needlessly doing it again.

- Use fds_copy.data() instead off address of indexing the vector.
Brian Gianforcaro 4 년 전
부모
커밋
4743afeaf4
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      Kernel/Syscalls/select.cpp

+ 2 - 2
Kernel/Syscalls/select.cpp

@@ -169,7 +169,7 @@ int Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_params)
         if (nfds_checked.has_overflow())
             return -EFAULT;
         fds_copy.resize(params.nfds);
-        if (!copy_from_user(&fds_copy[0], &params.fds[0], params.nfds * sizeof(pollfd)))
+        if (!copy_from_user(fds_copy.data(), &params.fds[0], nfds_checked.value()))
             return -EFAULT;
     }
 
@@ -242,7 +242,7 @@ int Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_params)
             fds_with_revents++;
     }
 
-    if (params.nfds > 0 && !copy_to_user(&params.fds[0], &fds_copy[0], params.nfds * sizeof(pollfd)))
+    if (params.nfds > 0 && !copy_to_user(&params.fds[0], fds_copy.data(), params.nfds * sizeof(pollfd)))
         return -EFAULT;
 
     return fds_with_revents;