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)
usbmuxd_log(LL_WARNING, "Endpoint count mismatch for interface %d of device %d-%d", intf->bInterfaceNumber, bus, address);
continue;
}
- if((intf->endpoint[0].bEndpointAddress & 0x80) != LIBUSB_ENDPOINT_OUT ||
- (intf->endpoint[1].bEndpointAddress & 0x80) != LIBUSB_ENDPOINT_IN) {
+ if((intf->endpoint[0].bEndpointAddress & 0x80) == LIBUSB_ENDPOINT_OUT &&
+ (intf->endpoint[1].bEndpointAddress & 0x80) == LIBUSB_ENDPOINT_IN) {
+ usbdev->interface = intf->bInterfaceNumber;
+ usbdev->ep_out = intf->endpoint[0].bEndpointAddress;
+ usbdev->ep_in = intf->endpoint[1].bEndpointAddress;
+ 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);
+ break;
+ } else if((intf->endpoint[1].bEndpointAddress & 0x80) == LIBUSB_ENDPOINT_OUT &&
+ (intf->endpoint[0].bEndpointAddress & 0x80) == LIBUSB_ENDPOINT_IN) {
+ usbdev->interface = intf->bInterfaceNumber;
+ usbdev->ep_out = intf->endpoint[1].bEndpointAddress;
+ usbdev->ep_in = intf->endpoint[0].bEndpointAddress;
+ 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);
+ break;
+ } else {
usbmuxd_log(LL_WARNING, "Endpoint type mismatch for interface %d of device %d-%d", intf->bInterfaceNumber, bus, address);
- continue;
}
- usbdev->interface = intf->bInterfaceNumber;
- usbdev->ep_out = intf->endpoint[0].bEndpointAddress;
- usbdev->ep_in = intf->endpoint[1].bEndpointAddress;
- 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);
- break;
}
libusb_free_config_descriptor(config);