summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Hector Martin2011-03-15 12:33:16 +0100
committerGravatar Hector Martin2011-03-15 12:33:16 +0100
commitb1b30622b461397485cd19e6d83b500793680271 (patch)
treed620ed402f891a3fc11832301aca1abfb70f1c94
parent32e27781dc6e4d2ef3508a0708284f22ee16ea1c (diff)
downloadusbmuxd-b1b30622b461397485cd19e6d83b500793680271.tar.gz
usbmuxd-b1b30622b461397485cd19e6d83b500793680271.tar.bz2
Handle devices with swapped endpoint descriptors
Reported by Adam Iglewski on an iPhone 2G running 1.1.4
-rw-r--r--daemon/usb-linux.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/daemon/usb-linux.c b/daemon/usb-linux.c
index 0860b46..c9d4629 100644
--- a/daemon/usb-linux.c
+++ b/daemon/usb-linux.c
@@ -334,16 +334,23 @@ int usb_discover(void)
334 usbmuxd_log(LL_WARNING, "Endpoint count mismatch for interface %d of device %d-%d", intf->bInterfaceNumber, bus, address); 334 usbmuxd_log(LL_WARNING, "Endpoint count mismatch for interface %d of device %d-%d", intf->bInterfaceNumber, bus, address);
335 continue; 335 continue;
336 } 336 }
337 if((intf->endpoint[0].bEndpointAddress & 0x80) != LIBUSB_ENDPOINT_OUT || 337 if((intf->endpoint[0].bEndpointAddress & 0x80) == LIBUSB_ENDPOINT_OUT &&
338 (intf->endpoint[1].bEndpointAddress & 0x80) != LIBUSB_ENDPOINT_IN) { 338 (intf->endpoint[1].bEndpointAddress & 0x80) == LIBUSB_ENDPOINT_IN) {
339 usbdev->interface = intf->bInterfaceNumber;
340 usbdev->ep_out = intf->endpoint[0].bEndpointAddress;
341 usbdev->ep_in = intf->endpoint[1].bEndpointAddress;
342 usbmuxd_log(LL_INFO, "Found interface %d with endpoints %02x/%02x for device %d-%d", usbdev->interface, usbdev->ep_out, usbdev->ep_in, bus, address);
343 break;
344 } else if((intf->endpoint[1].bEndpointAddress & 0x80) == LIBUSB_ENDPOINT_OUT &&
345 (intf->endpoint[0].bEndpointAddress & 0x80) == LIBUSB_ENDPOINT_IN) {
346 usbdev->interface = intf->bInterfaceNumber;
347 usbdev->ep_out = intf->endpoint[1].bEndpointAddress;
348 usbdev->ep_in = intf->endpoint[0].bEndpointAddress;
349 usbmuxd_log(LL_INFO, "Found interface %d with swapped endpoints %02x/%02x for device %d-%d", usbdev->interface, usbdev->ep_out, usbdev->ep_in, bus, address);
350 break;
351 } else {
339 usbmuxd_log(LL_WARNING, "Endpoint type mismatch for interface %d of device %d-%d", intf->bInterfaceNumber, bus, address); 352 usbmuxd_log(LL_WARNING, "Endpoint type mismatch for interface %d of device %d-%d", intf->bInterfaceNumber, bus, address);
340 continue;
341 } 353 }
342 usbdev->interface = intf->bInterfaceNumber;
343 usbdev->ep_out = intf->endpoint[0].bEndpointAddress;
344 usbdev->ep_in = intf->endpoint[1].bEndpointAddress;
345 usbmuxd_log(LL_INFO, "Found interface %d with endpoints %02x/%02x for device %d-%d", usbdev->interface, usbdev->ep_out, usbdev->ep_in, bus, address);
346 break;
347 } 354 }
348 libusb_free_config_descriptor(config); 355 libusb_free_config_descriptor(config);
349 356