diff options
author | dzwdz | 2021-09-05 17:43:59 +0200 |
---|---|---|
committer | dzwdz | 2021-09-05 17:43:59 +0200 |
commit | d703fb367f832ef28d70c9098f7acb0b6532b44b (patch) | |
tree | 9b91788fe78b9c260e2156442fa4ca5e9d9dbb9a /src | |
parent | f229b2e8a6ca840af8f3ac26cc2f412891a99a5e (diff) |
don't allow calling open() if there are no empty handles left
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/syscalls.c | 7 |
1 files changed, 4 insertions, 3 deletions
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); |