diff mbox

[U-Boot] usb: kbd: Prevent out of bound access

Message ID 1453756130-5306-1-git-send-email-marex@denx.de
State Accepted
Commit bdbcbe752e93357226cba12a6ce00bbe54cb5db8
Delegated to: Marek Vasut
Headers show

Commit Message

Marek Vasut Jan. 25, 2016, 9:08 p.m. UTC
Scan code 0x39 is CapsLock, which is not a printable character and thus
is not covered by either usb_kbd_numkey_shifted[] or usb_kbd_numkey[].
Fix the scan code check to avoid looking it up in either of the arrays.

Signed-off-by: Marek Vasut <marex@denx.de>
---
 common/usb_kbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tom Rini Jan. 25, 2016, 9:30 p.m. UTC | #1
On Mon, Jan 25, 2016 at 10:08:50PM +0100, Marek Vasut wrote:

> Scan code 0x39 is CapsLock, which is not a printable character and thus
> is not covered by either usb_kbd_numkey_shifted[] or usb_kbd_numkey[].
> Fix the scan code check to avoid looking it up in either of the arrays.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>

Reviewed-by: Tom Rini <trini@konsulko.com>
diff mbox

Patch

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index cbb1995..d84865f 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -199,7 +199,7 @@  static int usb_kbd_translate(struct usb_kbd_pdata *data, unsigned char scancode,
 		}
 	}
 
-	if ((scancode > 0x1d) && (scancode < 0x3a)) {
+	if ((scancode > 0x1d) && (scancode < 0x39)) {
 		/* Shift pressed */
 		if (modifier & (LEFT_SHIFT | RIGHT_SHIFT))
 			keycode = usb_kbd_numkey_shifted[scancode - 0x1e];