From: Marek Vasut Date: Mon, 25 Jan 2016 21:00:44 +0000 (+0100) Subject: usb: kbd: Prevent out of bound access X-Git-Tag: v2016.03-rc1~51^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bdbcbe752e93357226cba12a6ce00bbe54cb5db8;p=u-boot usb: kbd: Prevent out of bound access 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 --- diff --git a/common/usb_kbd.c b/common/usb_kbd.c index cbb1995de3..d84865fbbe 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];