diff options
Diffstat (limited to 'src/kernel/syscalls.c')
-rw-r--r-- | src/kernel/syscalls.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 4da5261..015bb17 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -131,15 +131,18 @@ fail: } int _syscall_fd_read(fd_t fd, char *buf, int len) { - return fdop_dispatch(FDOP_READ, fd, buf, len); + if (fd < 0 || fd >= FD_MAX) return -1; + return fdop_dispatch(FDOP_READ, &process_current->fds[fd], buf, len); } int _syscall_fd_write(fd_t fd, char *buf, int len) { - return fdop_dispatch(FDOP_WRITE, fd, buf, len); + if (fd < 0 || fd >= FD_MAX) return -1; + return fdop_dispatch(FDOP_WRITE, &process_current->fds[fd], buf, len); } int _syscall_fd_close(fd_t fd) { - return fdop_dispatch(FDOP_CLOSE, fd, 0, 0); + if (fd < 0 || fd >= FD_MAX) return -1; + return fdop_dispatch(FDOP_CLOSE, &process_current->fds[fd], 0, 0); } int _syscall_debuglog(const char *msg, size_t len) { |