From 6b085892a0e99c21ccb2d94a2edab91cc4f87ad1 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 8 Jul 2023 17:32:41 +0200 Subject: user/keyboard: check open() path this prevents someone from trying to `ls /keyboard/`, and makes `echo */*` in dash almost work if you mash the keyboard --- src/user/app/init/driver/ps2.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/user/app/init/driver/ps2.c b/src/user/app/init/driver/ps2.c index 4fee60a..2752238 100644 --- a/src/user/app/init/driver/ps2.c +++ b/src/user/app/init/driver/ps2.c @@ -1,9 +1,10 @@ #include "driver.h" +#include #include +#include #include #include #include -#include static const char keymap_lower[] = { @@ -55,9 +56,15 @@ static void main_loop(void) { struct ufs_request res; int ret; while (!c0_fs_wait(buf, sizeof buf, &res)) { + // TODO don't hang on ps2 reads + switch (res.op) { case VFSOP_OPEN: - c0_fs_respond(NULL, 1, 0); + if (res.len == 0) { + c0_fs_respond(NULL, 1, 0); + } else { + c0_fs_respond(NULL, -ENOENT, 0); + } break; case VFSOP_READ: -- cgit v1.2.3