From 05bc98a4109130b8a9bb48bd9a096181f908ac47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20H=C3=B8jelse?= <34659757+hojelse@users.noreply.github.com> Date: Fri, 26 May 2023 18:43:18 +0200 Subject: [PATCH] Kernel: Fix panic when switching to out-of-bounds console This was caused by an off-by-two error. Fixes #19034 --- Kernel/Devices/HID/KeyboardDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/Devices/HID/KeyboardDevice.cpp b/Kernel/Devices/HID/KeyboardDevice.cpp index 5b5aa668c3..27e3938812 100644 --- a/Kernel/Devices/HID/KeyboardDevice.cpp +++ b/Kernel/Devices/HID/KeyboardDevice.cpp @@ -253,7 +253,7 @@ void KeyboardDevice::handle_scan_code_input_event(ScanCodeEvent event) Scheduler::dump_scheduler_state(m_modifiers == (Mod_Ctrl | Mod_Alt | Mod_Shift)); } - if ((m_modifiers & Mod_Alt) != 0 && key >= Key_1 && key <= Key_1 + ConsoleManagement::s_max_virtual_consoles + 1) { + if ((m_modifiers & Mod_Alt) != 0 && key >= Key_1 && key < Key_1 + ConsoleManagement::s_max_virtual_consoles) { // FIXME: Do something sanely here if we can't allocate a work queue? MUST(g_io_work->try_queue([key]() { ConsoleManagement::the().switch_to(key - Key_1);