sixaxis: Fix device detection
PATCH 1/1 sixaxis: Fix device detection
After searching past the end of the structure, the loop sometimes found matches in the daemon's address space...
This fixes the loop to end after the elements have been exhausted.
--- plugins/sixaxis.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
plugins/sixaxis.c +2 -2
@@ -301,7 +301,7 @@ static int get_supported_device(struct udev_device *udevice, uint16_t *bus)struct udev_device *hid_parent;uint16_t vid, pid;const char *hid_id; -int i; +guint i; hid_parent =udev_device_get_parent_with_subsystem_devtype (udevice,"hid" ,NULL );
@@ -313,7 +313,7 @@ static int get_supported_device(struct udev_device *udevice, uint16_t *bus)if (sscanf (hid_id,"%hx:%hx:%hx" , bus, &vid, &pid) !=3 )return -1 ; -for (i =0 ;G_N_ELEMENTS (devices); i++) { +for (i =0 ; i <G_N_ELEMENTS (devices); i++) {if (devices[i].vid == vid && devices[i].pid == pid)return i; }
Signature · 1 line
1.8.4.2
Johan Hedberg
AppliedHi Bastien,
Quoted 7 lines · Bastien Nocera
After searching past the end of the structure, the loop sometimes found matches in the daemon's address space...
This fixes the loop to end after the elements have been exhausted.
--- plugins/sixaxis.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied. Thanks.
Johan