Refuse devices with more than 256 slots
We already had a limitation on synching a max of 256 slots, regardless what the device reports, this just extends the check to refuse any device with >256 slots. The kernel already limits to 99 slots for uinput devices so anything 256 and higher will be a malicious/buggy real device. We can't add a test to this because the kernel refuses uinput devices with more than 99 slots. Part-of: <https://gitlab.freedesktop.org/libevdev/libevdev/-/merge_requests/135>
This commit is contained in:
1 parent
75717d318d
commit
96c70d46f0
1 file changed
+6
-1
+6
-1
@@ -21,6 +21,7 @@
|
||||
#include "event-names.h"
|
||||
|
||||
#define MAXEVENTS 64
|
||||
#define MAX_SLOTS 256
|
||||
|
||||
enum event_filter_status {
|
||||
EVENT_FILTER_NONE, /**< Event untouched by filters */
|
||||
@@ -359,6 +360,11 @@ init_slots(struct libevdev *dev)
|
||||
|
||||
free_slots(dev);
|
||||
dev->num_slots = abs_info->maximum + 1;
|
||||
if (dev->num_slots > MAX_SLOTS) {
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
dev->mt_slot_vals = calloc(dev->num_slots * ABS_MT_CNT, sizeof(int));
|
||||
if (!dev->mt_slot_vals) {
|
||||
rc = -ENOMEM;
|
||||
@@ -665,7 +671,6 @@ static int
|
||||
sync_mt_state(struct libevdev *dev,
|
||||
struct slot_change_state changes_out[dev->num_slots])
|
||||
{
|
||||
#define MAX_SLOTS 256
|
||||
int rc = 0;
|
||||
struct slot_change_state changes[MAX_SLOTS] = {0};
|
||||
unsigned int nslots = min(MAX_SLOTS, dev->num_slots);
|
||||
|
||||
Reference in new issue
Block a user