summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Campbell <ijc@hellion.org.uk>2005-09-04 01:41:14 -0500
committerDmitry Torokhov <dtor_core@ameritech.net>2005-09-04 01:41:14 -0500
commit4cee99564db7f65a6f88e4b752da52768cde3802 (patch)
tree6c355494c3c399d2c1fc2d746171f434ded907e4
parentd2b5ffca73594e4046f405e3ef2438ce41f76fb2 (diff)
downloadblackbird-op-linux-4cee99564db7f65a6f88e4b752da52768cde3802.tar.gz
blackbird-op-linux-4cee99564db7f65a6f88e4b752da52768cde3802.zip
Input: fix checking whether new keycode fits size-wise
When dev->keycodesize == sizeof(int) the old code produces incorrect result. Signed-off-by: Ian Campbell <ijc@hellion.org.uk> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/char/keyboard.c2
-rw-r--r--drivers/input/evdev.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 523fd3c8bbaa..1ddaabeb8ef8 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -200,7 +200,7 @@ int setkeycode(unsigned int scancode, unsigned int keycode)
return -EINVAL;
if (keycode < 0 || keycode > KEY_MAX)
return -EINVAL;
- if (keycode >> (dev->keycodesize * 8))
+ if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8)))
return -EINVAL;
oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode);
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 20e3a165989f..3a8314bb7902 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -320,7 +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;
+ if (dev->keycodesize < sizeof(v) && (v >> (dev->keycodesize * 8))) return -EINVAL;
u = SET_INPUT_KEYCODE(dev, t, v);
clear_bit(u, dev->keybit);
set_bit(v, dev->keybit);
OpenPOWER on IntegriCloud