From 2332655423c1616d8e37ece7f33e98be0e218504 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 12 Jul 2019 18:45:46 +0700 Subject: Fix service startup in idevicecrashreport for iOS 13 --- tools/idevicecrashreport.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tools/idevicecrashreport.c b/tools/idevicecrashreport.c index d0b2c7a..533265c 100644 --- a/tools/idevicecrashreport.c +++ b/tools/idevicecrashreport.c @@ -30,9 +30,10 @@ #include #include "common/utils.h" -#include -#include #include +#include +#include +#include #include #ifdef WIN32 @@ -55,7 +56,8 @@ static int file_exists(const char* path) #endif } -static int extract_raw_crash_report(const char* filename) { +static int extract_raw_crash_report(const char* filename) +{ int res = 0; plist_t report = NULL; char* raw = NULL; @@ -307,7 +309,8 @@ static void print_usage(int argc, char **argv) printf("Homepage: <" PACKAGE_URL ">\n"); } -int main(int argc, char* argv[]) { +int main(int argc, char* argv[]) +{ idevice_t device = NULL; lockdownd_client_t lockdownd = NULL; afc_client_t afc = NULL; @@ -396,9 +399,11 @@ int main(int argc, char* argv[]) { } /* trigger move operation on device */ - idevice_connection_t connection = NULL; - device_error = idevice_connect(device, service->port, &connection); - if(device_error != IDEVICE_E_SUCCESS) { + service_client_t svcmove = NULL; + service_error_t service_error = service_client_new(device, service, &svcmove); + lockdownd_service_descriptor_free(service); + service = NULL; + if (service_error != SERVICE_E_SUCCESS) { lockdownd_client_free(lockdownd); idevice_free(device); return -1; @@ -410,23 +415,18 @@ int main(int argc, char* argv[]) { int attempts = 0; while ((strncmp(ping, "ping", 4) != 0) && (attempts < 10)) { uint32_t bytes = 0; - device_error = idevice_connection_receive_timeout(connection, ping, 4, &bytes, 2000); - if (device_error != IDEVICE_E_SUCCESS) { + service_error = service_receive_with_timeout(svcmove, ping, 4, &bytes, 2000); + if (service_error == SERVICE_E_SUCCESS || service_error == SERVICE_E_TIMEOUT) { attempts++; continue; - } else if (device_error < 0) { - fprintf(stderr, "ERROR: Crash logs could not be moved. Connection interrupted.\n"); + } else { + fprintf(stderr, "ERROR: Crash logs could not be moved. Connection interrupted (%d).\n", service_error); break; } } - idevice_disconnect(connection); + service_client_free(svcmove); free(ping); - if (service) { - lockdownd_service_descriptor_free(service); - service = NULL; - } - if (device_error != IDEVICE_E_SUCCESS || attempts > 10) { fprintf(stderr, "ERROR: Failed to receive ping message from crash report mover.\n"); lockdownd_client_free(lockdownd); -- cgit v1.1-32-gdbae