diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2013-02-27 19:57:28 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2013-02-27 19:57:28 +0000 |
commit | fa2a8fca69513d59b008159361ed741a753b6304 (patch) | |
tree | 3b3200204c8313b58f1f5371a57e97422ae13498 /LUFA/Drivers/USB/Class | |
parent | 95fd3bf0fe44a76047f1598d993e523db9b1139f (diff) | |
download | lufa-fa2a8fca69513d59b008159361ed741a753b6304.tar.gz lufa-fa2a8fca69513d59b008159361ed741a753b6304.tar.bz2 lufa-fa2a8fca69513d59b008159361ed741a753b6304.zip |
Fixed potential NULL pointer dereference in the HID Host mode Class Driver (thanks to Pavel Kuzmin).
Diffstat (limited to 'LUFA/Drivers/USB/Class')
-rw-r--r-- | LUFA/Drivers/USB/Class/Host/HIDClassHost.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/LUFA/Drivers/USB/Class/Host/HIDClassHost.c b/LUFA/Drivers/USB/Class/Host/HIDClassHost.c index 5e1ad3724..837c84100 100644 --- a/LUFA/Drivers/USB/Class/Host/HIDClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/HIDClassHost.c @@ -57,7 +57,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, DCOMP_HID_Host_NextHIDInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { - if (DataINEndpoint || DataOUTEndpoint) + if (DataINEndpoint) break; do @@ -97,16 +97,19 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo HIDInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize); HIDInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress; HIDInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_INTERRUPT; - - HIDInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); - HIDInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; - HIDInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_INTERRUPT; - + if (!(Pipe_ConfigurePipeTable(&HIDInterfaceInfo->Config.DataINPipe, 1))) return false; - - if (!(Pipe_ConfigurePipeTable(&HIDInterfaceInfo->Config.DataOUTPipe, 1))) - return false; + + if (DataOUTEndpoint) + { + HIDInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); + HIDInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; + HIDInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_INTERRUPT; + + if (!(Pipe_ConfigurePipeTable(&HIDInterfaceInfo->Config.DataOUTPipe, 1))) + return false; + } HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber; HIDInterfaceInfo->State.HIDReportSize = LE16_TO_CPU(HIDDescriptor->HIDReportLength); |