提交 ac3c9a94 编写于 作者: F Frank Praznik 提交者: Jiri Kosina

HID: sony: Perform a boundry check on the sixaxis battery level index.

Make sure that an out-of-bounds read doesn't occur in the Sixaxis battery level
lookup table in the event that the controller sends an invalid battery status
value in the report.
Signed-off-by: NFrank Praznik <frank.praznik@oh.rr.com>
Reviewed-by: NDavid Herrmann <dh.herrmann@gmail.com>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 c8de9dbb
......@@ -854,7 +854,8 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
battery_capacity = 100;
battery_charging = !(rd[30] & 0x01);
} else {
battery_capacity = sixaxis_battery_capacity[rd[30]];
__u8 index = rd[30] <= 5 ? rd[30] : 5;
battery_capacity = sixaxis_battery_capacity[index];
battery_charging = 0;
}
cable_state = !((rd[31] >> 4) & 0x01);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册