summaryrefslogtreecommitdiff
path: root/platform/x11
diff options
context:
space:
mode:
authorHubert Jarosz <marqin.pl+git@gmail.com>2016-02-28 20:20:59 +0100
committerHubert Jarosz <marqin.pl@gmail.com>2016-03-09 00:16:56 +0100
commit4b14c18d1334d65c6b1949dfbb554037448fd59f (patch)
tree1b48669a25cc1d68df591fdfb8ef1ca857081c24 /platform/x11
parente46e43d2aaa6339a1675eb989f41885e745bf5c3 (diff)
fix possible crash in platform/x11/joystick_linux.cpp
ev may be tainted and out of MAX_KEY range, which will cause joy->key_map[ev.code] to crash
Diffstat (limited to 'platform/x11')
-rw-r--r--platform/x11/joystick_linux.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/platform/x11/joystick_linux.cpp b/platform/x11/joystick_linux.cpp
index 9a52c4ff36..0615f33f96 100644
--- a/platform/x11/joystick_linux.cpp
+++ b/platform/x11/joystick_linux.cpp
@@ -429,6 +429,12 @@ uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) {
for (int j = 0; j < len; j++) {
input_event &ev = events[j];
+
+ // ev may be tainted and out of MAX_KEY range, which will cause
+ // joy->key_map[ev.code] to crash
+ if( ev.code < 0 || ev.code >= MAX_KEY )
+ return p_event_id;
+
switch (ev.type) {
case EV_KEY:
p_event_id = input->joy_button(p_event_id, i, joy->key_map[ev.code], ev.value);