diff options
author | Marvin Borner | 2021-04-25 16:31:40 +0200 |
---|---|---|
committer | Marvin Borner | 2021-04-25 16:31:40 +0200 |
commit | 0fe14a1ff936c38ab9aa7f85219d0c155d276823 (patch) | |
tree | b3e4b1f9000819a564656fabf0496f871c1e6eba /kernel/features/fs.c | |
parent | f2b4acb2fe6a366288b19843e0d2678b8590bdf4 (diff) |
Added range-based memory validator
Diffstat (limited to 'kernel/features/fs.c')
-rw-r--r-- | kernel/features/fs.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/kernel/features/fs.c b/kernel/features/fs.c index 34c70e8..6cb10c8 100644 --- a/kernel/features/fs.c +++ b/kernel/features/fs.c @@ -147,7 +147,7 @@ res vfs_read(const char *path, void *buf, u32 offset, u32 count) if (!memory_readable(path)) return -EFAULT; - if (!memory_writable(buf)) + if (!memory_writable_range(memory_range(buf, count))) return -EFAULT; struct mount_info *m = vfs_find_mount_info(path); @@ -170,12 +170,12 @@ res vfs_read(const char *path, void *buf, u32 offset, u32 count) return m->dev->vfs->read(path, buf, offset, count, m->dev); } -res vfs_write(const char *path, void *buf, u32 offset, u32 count) +res vfs_write(const char *path, const void *buf, u32 offset, u32 count) { if (!memory_readable(path)) return -EFAULT; - if (!memory_writable(buf)) + if (!memory_readable_range(memory_range(buf, count))) return -EFAULT; struct mount_info *m = vfs_find_mount_info(path); @@ -203,7 +203,7 @@ res vfs_stat(const char *path, struct stat *buf) if (!memory_readable(path)) return -EFAULT; - if (!memory_writable(buf)) + if (!memory_writable_range(memory_range(buf, sizeof(*buf)))) return -EFAULT; struct mount_info *m = vfs_find_mount_info(path); |