From 5947b9c89b753b32d2e56b6c9ab2f62bbe09310b Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 11 Apr 2022 22:55:08 +0200 Subject: kernel/rootvfs: don't overread from ps2/serial --- src/kernel/vfs/root.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/kernel/vfs/root.c') diff --git a/src/kernel/vfs/root.c b/src/kernel/vfs/root.c index b5f7a8a..2529b02 100644 --- a/src/kernel/vfs/root.c +++ b/src/kernel/vfs/root.c @@ -107,7 +107,7 @@ static int handle(struct vfs_request *req, bool *ready) { return -1; } uint8_t buf[16]; - size_t len = serial_read(buf, sizeof buf); + size_t len = serial_read(buf, min(req->output.len, sizeof buf)); virt_cpy_to(req->caller->pages, req->output.buf, buf, len); return len; } @@ -123,7 +123,7 @@ static int handle(struct vfs_request *req, bool *ready) { return -1; } uint8_t buf[16]; - size_t len = ps2_read(buf, sizeof buf); + size_t len = ps2_read(buf, min(req->output.len, sizeof buf)); virt_cpy_to(req->caller->pages, req->output.buf, buf, len); return len; } -- cgit v1.2.3