Cap slot values to the announced maximum
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 5 Mar 2014 00:57:01 +0000 (10:57 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 6 Mar 2014 04:30:03 +0000 (14:30 +1000)
commit66fee1bec4c4b021e1b54adcd775cf6e2aa84869
tree416f1f2b156f783709d516eb84a86e760220b6f3
parent4ba56ac30995f85bc492b5154c40cb05e1053e57
Cap slot values to the announced maximum

A malicious device may announce N slots but then send a slot index >= N. The
slot state is almost always allocated (definitely the case in libevdev and
true for most callers), so providing a slot number higher than the announced
maximum is likely to lead to invalid dereferences. Don't allow that.
Likewise, don't allow negative slot numbers.

Note that the kernel filters these events anyway, the only way to trigger this
is to change the device fd to something outside the kernel's control.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
libevdev/libevdev.c
libevdev/libevdev.h
test/test-libevdev-events.c