瀏覽代碼

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
Hubert Jarosz 9 年之前
父節點
當前提交
4b14c18d13
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      platform/x11/joystick_linux.cpp

+ 6 - 0
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);