diff options
author | Ian Moffett <ian@osmora.org> | 2024-11-04 01:38:46 -0500 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-11-04 01:38:46 -0500 |
commit | 604d40fce6b7e69e9494de7381071315536335db (patch) | |
tree | 87950fe94670ea7d7fad2838c12f4d9ca86b613c /sys/kern/vfs_syscalls.c | |
parent | fab307311f6e1e87f1c3580b03c5a3e36d1b2645 (diff) |
kernel: descrip: Only use copyinstr() in SYS_open
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/kern/vfs_syscalls.c')
-rw-r--r-- | sys/kern/vfs_syscalls.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 0ef3d42..fc85759 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -83,6 +83,18 @@ vfs_dostat(const char *path, struct stat *sbuf) return 0; } +static int +vfs_doopen(const char *pathname, int flags) +{ + char pathbuf[PATH_MAX]; + + if (copyinstr(pathname, pathbuf, PATH_MAX) < 0) { + return -EFAULT; + } + + return fd_open(pathbuf, flags); +} + /* * arg0: pathname * arg1: oflags @@ -92,7 +104,7 @@ vfs_dostat(const char *path, struct stat *sbuf) scret_t sys_open(struct syscall_args *scargs) { - return fd_open((char *)scargs->arg0, scargs->arg1); + return vfs_doopen((char *)scargs->arg0, scargs->arg1); } /* |