Skip to content

Commit

Permalink
HID: sony: Perform a boundry check on the sixaxis battery level index.
Browse files Browse the repository at this point in the history
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: Frank Praznik <frank.praznik@oh.rr.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Frank Praznik authored and Jiri Kosina committed Feb 24, 2014
1 parent c8de9db commit ac3c9a9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/hid/hid-sony.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ac3c9a9

Please sign in to comment.