hidraw hid_enumerate issue with vendor / product IDs #609

Closed
opened 2023-08-13 21:10:30 -05:00 by ghost · 2 comments
ghost commented 2023-08-13 21:10:30 -05:00 (Migrated from github.com)

The current code for hid_enumerate does not properly handle zero value product and vendor IDs. At present the code will check both product and vendor IDs for matches if either of them is non-zero, due to this conditional: vendor_id != 0 || product_id != 0. However the public header documentation implies they should be considered separately and not as a group. This is to allow you to get all devices matching the vendor id, product id, or both, or all devices period. However hidraw as written will only return devices matching both or all devices (if both are zero).

The current code for `hid_enumerate` does not properly handle zero value product and vendor IDs. At present the code will check both product and vendor IDs for matches if either of them is non-zero, due to this conditional: `vendor_id != 0 || product_id != 0`. However the public header documentation implies they should be considered separately and not as a group. This is to allow you to get all devices matching the vendor id, product id, or both, or all devices period. However `hidraw` as written will only return devices matching both or all devices (if both are zero).
Youw commented 2023-08-14 04:30:31 -05:00 (Migrated from github.com)

I don't believe that's true.
There lines are making sure of that.

Is your observation based on visual code analysys or a result of your testing?

I don't believe that's true. [There](https://github.com/libusb/hidapi/blob/5fd7a79b37ee4981a699558e280ba3102c463770/linux/hid.c#L893-L896) lines are making sure of that. Is your observation based on visual code analysys or a result of your testing?
ghost commented 2023-08-14 04:37:23 -05:00 (Migrated from github.com)

Nevermind, I got the impression because of the outer conditional.

Nevermind, I got the impression because of the outer conditional.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi#609
No description provided.