From f574c22f86d90f735107fda199bb5b4982cd9621 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 14 Mar 2015 15:11:29 +0100 Subject: Fix write of null length to channel ; fix cat. --- src/kernel/user/vfs.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/kernel') diff --git a/src/kernel/user/vfs.c b/src/kernel/user/vfs.c index fa226f8..0cb7f3f 100644 --- a/src/kernel/user/vfs.c +++ b/src/kernel/user/vfs.c @@ -497,6 +497,8 @@ void unref_file(fs_handle_t *file) { } size_t file_read(fs_handle_t *f, size_t offset, size_t len, char* buf) { + if (len == 0) return 0; + if (!(f->mode & FM_READ)) return 0; if (f->node->ops->read == 0) return 0; @@ -505,6 +507,8 @@ size_t file_read(fs_handle_t *f, size_t offset, size_t len, char* buf) { } size_t file_write(fs_handle_t *f, size_t offset, size_t len, const char* buf) { + if (len == 0) return 0; + if (!(f->mode & FM_WRITE)) return 0; if (f->node->ops->write == 0) return 0; -- cgit v1.2.3