Input: check keycodesize when adjusting keymaps
authorVojtech Pavlik <vojtech@suse.cz>
Sun, 24 Jul 2005 05:50:03 +0000 (00:50 -0500)
committerDmitry Torokhov <dtor_core@ameritech.net>
Sun, 24 Jul 2005 05:50:03 +0000 (00:50 -0500)
When changing key mappings we need to make sure that the new
keycode value can be stored in dev->keycodesize bytes.

Signed-off-by: Vojtech Pavlik <vojtech@suse.cz>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/char/keyboard.c
drivers/input/evdev.c

index 7b19e02f112fd585d02fe48e4eb1eb8c2a0001cc..523fd3c8bbaa75dd345224799990ec0c4f4e5e93 100644 (file)
@@ -198,10 +198,10 @@ int setkeycode(unsigned int scancode, unsigned int keycode)
 
        if (scancode >= dev->keycodemax)
                return -EINVAL;
-       if (keycode > KEY_MAX)
-               return -EINVAL;
        if (keycode < 0 || keycode > KEY_MAX)
                return -EINVAL;
+       if (keycode >> (dev->keycodesize * 8))
+               return -EINVAL;
 
        oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode);
 
index 374f404e81da32592596953b4403fc6571ca9f41..20e3a165989fb943b0ce29a2009120ce86b57f0b 100644 (file)
@@ -320,6 +320,7 @@ static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                        if (t < 0 || t >= dev->keycodemax || !dev->keycodesize) return -EINVAL;
                        if (get_user(v, ip + 1)) return -EFAULT;
                        if (v < 0 || v > KEY_MAX) return -EINVAL;
+                       if (v >> (dev->keycodesize * 8)) return -EINVAL;
                        u = SET_INPUT_KEYCODE(dev, t, v);
                        clear_bit(u, dev->keybit);
                        set_bit(v, dev->keybit);