From 008ac1574e127162f095a75f63c4c1be5d03b6d0 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 12 Apr 2022 19:44:38 +0200 Subject: kernel: make all sizes unsigned, sort out the sign mess --- src/kernel/syscalls.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/kernel/syscalls.c') diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 85db57a..dfd7dd4 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -125,7 +125,7 @@ fail: return -1; } -int _syscall_read(handle_t handle_num, void __user *buf, int len, int offset) { +int _syscall_read(handle_t handle_num, void __user *buf, size_t len, int offset) { struct handle *handle = &process_current->handles[handle_num]; if (handle_num < 0 || handle_num >= HANDLE_MAX) return -1; if (handle->type != HANDLE_FILE) return -1; @@ -142,7 +142,7 @@ int _syscall_read(handle_t handle_num, void __user *buf, int len, int offset) { }); } -int _syscall_write(handle_t handle_num, const void __user *buf, int len, int offset) { +int _syscall_write(handle_t handle_num, const void __user *buf, size_t len, int offset) { struct handle *handle = &process_current->handles[handle_num]; if (handle_num < 0 || handle_num >= HANDLE_MAX) return -1; if (handle->type != HANDLE_FILE) return -1; @@ -228,8 +228,7 @@ int _syscall_fs_respond(char __user *buf, int ret) { if (req->output.len > 0 && ret > 0) { // if this vfsop outputs data and ret is positive, it's the length of the buffer // TODO document - if (ret > req->output.len) - ret = req->output.len; // i'm not handling this in a special way - the fs server can prevent this on its own + ret = min(ret, capped_cast32(req->output.len)); if (!virt_cpy(req->caller->pages, req->output.buf, process_current->pages, buf, ret)) { // how should this error even be handled? TODO -- cgit v1.2.3