aboutsummaryrefslogtreecommitdiff
path: root/kernel/features/fs.c
diff options
context:
space:
mode:
authorMarvin Borner2021-04-25 16:31:40 +0200
committerMarvin Borner2021-04-25 16:31:40 +0200
commit0fe14a1ff936c38ab9aa7f85219d0c155d276823 (patch)
treeb3e4b1f9000819a564656fabf0496f871c1e6eba /kernel/features/fs.c
parentf2b4acb2fe6a366288b19843e0d2678b8590bdf4 (diff)
Added range-based memory validator
Diffstat (limited to 'kernel/features/fs.c')
-rw-r--r--kernel/features/fs.c8
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);