summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mrmacete2018-03-30 15:38:43 +0200
committerGravatar Nikias Bassen2019-07-17 01:38:02 +0700
commit1f8ddeff95884da404a7fbd74d27e04ca8c99a50 (patch)
tree4e5f8ed29492d5b8ae3611a2ffe924f7915f6310
parent8bcbac4d0bf857ef2ccbaf5be4f7af3613f4f5df (diff)
downloadusbmuxd-1f8ddeff95884da404a7fbd74d27e04ca8c99a50.tar.gz
usbmuxd-1f8ddeff95884da404a7fbd74d27e04ca8c99a50.tar.bz2
Avoid using configuration 5
- this fixes setting configuration for iOS 11 devices inside virtual machines which caused timeout and subsequent reboot of the device when unplugged from USB
-rw-r--r--src/usb.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/usb.c b/src/usb.c
index b659d90..364930c 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -392,13 +392,17 @@ static int usb_device_add(libusb_device* dev)
return -1;
}
+ int desired_config = devdesc.bNumConfigurations;
+ if (desired_config > 4) {
+ desired_config = 4;
+ }
int current_config = 0;
if((res = libusb_get_configuration(handle, &current_config)) != 0) {
usbmuxd_log(LL_WARNING, "Could not get configuration for device %d-%d: %d", bus, address, res);
libusb_close(handle);
return -1;
}
- if (current_config != devdesc.bNumConfigurations) {
+ if (current_config != desired_config) {
struct libusb_config_descriptor *config;
if((res = libusb_get_active_config_descriptor(dev, &config)) != 0) {
usbmuxd_log(LL_NOTICE, "Could not get old configuration descriptor for device %d-%d: %d", bus, address, res);
@@ -420,9 +424,9 @@ static int usb_device_add(libusb_device* dev)
libusb_free_config_descriptor(config);
}
- usbmuxd_log(LL_INFO, "Setting configuration for device %d-%d, from %d to %d", bus, address, current_config, devdesc.bNumConfigurations);
- if((res = libusb_set_configuration(handle, devdesc.bNumConfigurations)) != 0) {
- usbmuxd_log(LL_WARNING, "Could not set configuration %d for device %d-%d: %d", devdesc.bNumConfigurations, bus, address, res);
+ usbmuxd_log(LL_INFO, "Setting configuration for device %d-%d, from %d to %d", bus, address, current_config, desired_config);
+ if((res = libusb_set_configuration(handle, desired_config)) != 0) {
+ usbmuxd_log(LL_WARNING, "Could not set configuration %d for device %d-%d: %d", desired_config, bus, address, res);
libusb_close(handle);
return -1;
}