From d703fb367f832ef28d70c9098f7acb0b6532b44b Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 5 Sep 2021 17:43:59 +0200 Subject: don't allow calling open() if there are no empty handles left --- src/kernel/syscalls.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 4718b4b..93f7e44 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -70,12 +70,13 @@ handle_t _syscall_fs_open(const user_ptr path, int len) { struct virt_iter iter; struct vfs_mount *mount; static char buffer[PATH_MAX]; // holds the path - int handle, res; + int res; if (len > PATH_MAX) return -1; - // find the first free handle - handle = process_find_handle(process_current); + // fail if there are no handles left + if (process_find_handle(process_current) < 0) + return -1; // copy the path to the kernel virt_iter_new(&iter, path, len, process_current->pages, true, false); -- cgit v1.2.3