summaryrefslogtreecommitdiff
path: root/src/kernel/vfs/root.c
diff options
context:
space:
mode:
authordzwdz2022-04-11 22:55:08 +0200
committerdzwdz2022-04-11 22:55:08 +0200
commit5947b9c89b753b32d2e56b6c9ab2f62bbe09310b (patch)
tree5245f525b7f16fc368159d1588a4a35eba64a14f /src/kernel/vfs/root.c
parent0ed2c976cc0bf569a3901be686a467150c089896 (diff)
kernel/rootvfs: don't overread from ps2/serial
Diffstat (limited to 'src/kernel/vfs/root.c')
-rw-r--r--src/kernel/vfs/root.c4
1 files changed, 2 insertions, 2 deletions
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;
}