diff --git a/Kernel/Process.h b/Kernel/Process.h index f1df0d10d8..f5732aaaa1 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -268,7 +268,7 @@ public: int sys$ioctl(int fd, unsigned request, FlatPtr arg); int sys$mkdir(const char* pathname, size_t path_length, mode_t mode); clock_t sys$times(tms*); - int sys$utime(const char* pathname, size_t path_length, const struct utimbuf*); + int sys$utime(Userspace pathname, size_t path_length, Userspace); int sys$link(const Syscall::SC_link_params*); int sys$unlink(const char* pathname, size_t path_length); int sys$symlink(const Syscall::SC_symlink_params*); @@ -379,6 +379,16 @@ public: return validate_read(value, size.value()); } + template + [[nodiscard]] bool validate_read_typed(Userspace value, size_t count = 1) + { + Checked size = sizeof(T); + size *= count; + if (size.has_overflow()) + return false; + return validate_read(value, size.value()); + } + template [[nodiscard]] bool validate_read_and_copy_typed(T* dest, const T* src) { diff --git a/Kernel/Syscalls/utime.cpp b/Kernel/Syscalls/utime.cpp index 1fa6acc635..c7134eb330 100644 --- a/Kernel/Syscalls/utime.cpp +++ b/Kernel/Syscalls/utime.cpp @@ -30,7 +30,7 @@ namespace Kernel { -int Process::sys$utime(const char* user_path, size_t path_length, const utimbuf* user_buf) +int Process::sys$utime(Userspace user_path, size_t path_length, Userspace user_buf) { REQUIRE_PROMISE(fattr); if (user_buf && !validate_read_typed(user_buf))