aboutsummaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@arduino.cc>2015-10-08 16:38:57 +0200
committerCristian Maglie <c.maglie@arduino.cc>2015-10-08 16:38:57 +0200
commitf2d7b52e1b53b8e7266d3d82f8c8f68281b25d61 (patch)
tree41891809cf146d99b330662ecd7588d5d8da5bfc /libraries
parentabd6b795c412cf1b2d21338ace3a34f4984add42 (diff)
[HID] Improved checks in getDescriptor() method
Diffstat (limited to 'libraries')
-rw-r--r--libraries/HID/HID.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/libraries/HID/HID.cpp b/libraries/HID/HID.cpp
index 762d170..bff00e3 100644
--- a/libraries/HID/HID.cpp
+++ b/libraries/HID/HID.cpp
@@ -40,9 +40,12 @@ int HID_::getInterface(uint8_t* interfaceCount)
int HID_::getDescriptor(USBSetup& setup)
{
- if (pluggedInterface != setup.wIndex) {
- return 0;
- }
+ // Check if this is a HID Class Descriptor request
+ if (setup.bmRequestType != REQUEST_DEVICETOHOST_STANDARD_INTERFACE) { return 0; }
+ if (setup.wValueH != HID_REPORT_DESCRIPTOR_TYPE) { return 0; }
+
+ // In a HID Class Descriptor wIndex cointains the interface number
+ if (setup.wIndex != pluggedInterface) { return 0; }
int total = 0;
HIDDescriptorListNode* node;