summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2018-09-11 00:15:41 +0200
committerGravatar Nikias Bassen2018-09-11 00:15:41 +0200
commit96b0c2eb571498749c9e8b926c02559f6956e273 (patch)
treeb1bd7b1d81390d05f8b8735c58f91a653090ed2d /src
parentf1d7ac2ba8f598fce0135af4894b2f7cf3c03a9d (diff)
downloadlibirecovery-96b0c2eb571498749c9e8b926c02559f6956e273.tar.gz
libirecovery-96b0c2eb571498749c9e8b926c02559f6956e273.tar.bz2
win32: REALLY Fix parsing of usb device path so it works again with older drivers
Diffstat (limited to 'src')
-rw-r--r--src/libirecovery.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c
index 5fc07ba..df9fde6 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -569,9 +569,14 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, unsigned long long ec
}
char serial_str[256];
- char *p = strrchr(result, '\\');
+ char *p = result + strlen(result) - 1;
+ while (p-- && p > result) {
+ if (*p == '\\' && (strncmp(p, "\\usb", 4) == 0)) {
+ break;
+ }
+ }
serial_str[0] = '\0';
- if (!p && (sscanf(p, "\\usb#vid_%*04x&pid_%*04x#%s", serial_str) != 1) || (serial_str[0] == '\0')) {
+ if (!p || (sscanf(p, "\\usb#vid_%*04x&pid_%*04x#%s", serial_str) != 1) || (serial_str[0] == '\0')) {
mobiledevice_closepipes(_client);
continue;
}
@@ -646,7 +651,12 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, unsigned long long ec
}
char serial_str[256];
- char *p = strrchr(result, '\\');
+ char *p = result + strlen(result) - 1;
+ while (p-- && p > result) {
+ if (*p == '\\' && (strncmp(p, "\\usb", 4) == 0)) {
+ break;
+ }
+ }
serial_str[0] = '\0';
if (!p || (sscanf(p, "\\usb#vid_%*04x&pid_%*04x#%s", serial_str) != 1) || (serial_str[0] == '\0')) {
mobiledevice_closepipes(_client);