From ffd40983ac5b8d449d2c6c08367bf37b724de8a5 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 20 Sep 2024 08:28:44 +0200 Subject: [PATCH] [locale,keyboard] fix index range checks --- libfreerdp/locale/keyboard.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libfreerdp/locale/keyboard.c b/libfreerdp/locale/keyboard.c index 6eebd6554..56b6f477f 100644 --- a/libfreerdp/locale/keyboard.c +++ b/libfreerdp/locale/keyboard.c @@ -373,7 +373,7 @@ DWORD freerdp_keyboard_init_ex(DWORD keyboardLayoutId, const char* keyboardRemap DWORD freerdp_keyboard_get_rdp_scancode_from_x11_keycode(DWORD keycode) { - if (keycode > ARRAYSIZE(X11_KEYCODE_TO_VIRTUAL_SCANCODE)) + if (keycode >= ARRAYSIZE(X11_KEYCODE_TO_VIRTUAL_SCANCODE)) { WLog_ERR(TAG, "KeyCode %" PRIu32 " exceeds allowed value range [0,%" PRIuz "]", keycode, ARRAYSIZE(X11_KEYCODE_TO_VIRTUAL_SCANCODE)); @@ -381,7 +381,7 @@ DWORD freerdp_keyboard_get_rdp_scancode_from_x11_keycode(DWORD keycode) } const DWORD scancode = X11_KEYCODE_TO_VIRTUAL_SCANCODE[keycode]; - if (scancode > ARRAYSIZE(REMAPPING_TABLE)) + if (scancode >= ARRAYSIZE(REMAPPING_TABLE)) { WLog_ERR(TAG, "ScanCode %" PRIu32 " exceeds allowed value range [0,%" PRIuz "]", scancode, ARRAYSIZE(REMAPPING_TABLE)); @@ -414,7 +414,7 @@ DWORD freerdp_keyboard_get_rdp_scancode_from_x11_keycode(DWORD keycode) DWORD freerdp_keyboard_get_x11_keycode_from_rdp_scancode(DWORD scancode, BOOL extended) { - if (scancode > ARRAYSIZE(VIRTUAL_SCANCODE_TO_X11_KEYCODE)) + if (scancode >= ARRAYSIZE(VIRTUAL_SCANCODE_TO_X11_KEYCODE)) { WLog_ERR(TAG, "ScanCode %" PRIu32 " exceeds allowed value range [0,%" PRIuz "]", scancode, ARRAYSIZE(VIRTUAL_SCANCODE_TO_X11_KEYCODE));