diff --git a/kernel/src/sys/file.cpp b/kernel/src/sys/file.cpp index 3838af14..cc97aaf5 100644 --- a/kernel/src/sys/file.cpp +++ b/kernel/src/sys/file.cpp @@ -16,6 +16,8 @@ Result sys_read(Registers*, SyscallArgs args) u8* buf = (u8*)args[1]; usize size = (usize)args[2]; + if (!size) return 0; + if (!MemoryManager::validate_user_write(buf, size)) return err(EFAULT); Thread* current = Scheduler::current(); @@ -44,6 +46,8 @@ Result sys_write(Registers*, SyscallArgs args) const u8* buf = (const u8*)args[1]; usize size = (usize)args[2]; + if (!size) return 0; + if (!MemoryManager::validate_user_read(buf, size)) return err(EFAULT); Thread* current = Scheduler::current();