diff options
| author | 2013-03-14 03:09:14 +0100 | |
|---|---|---|
| committer | 2013-03-14 03:09:14 +0100 | |
| commit | 4222bc1b880d6535462e3b5ba5431809a3c5fddc (patch) | |
| tree | b664bbdfe96d162930b2719ec920cd149684b0ed /tools | |
| parent | 23abc8303b8cad9251cd4ea4b5fa5af28e5f0b24 (diff) | |
| download | libimobiledevice-4222bc1b880d6535462e3b5ba5431809a3c5fddc.tar.gz libimobiledevice-4222bc1b880d6535462e3b5ba5431809a3c5fddc.tar.bz2 | |
global: make sure to check service before checking service->port to prevent crashes
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/idevicebackup.c | 11 | ||||
| -rw-r--r-- | tools/idevicebackup2.c | 11 | ||||
| -rw-r--r-- | tools/idevicedebugserverproxy.c | 2 | ||||
| -rw-r--r-- | tools/idevicediagnostics.c | 2 | ||||
| -rw-r--r-- | tools/ideviceimagemounter.c | 4 | ||||
| -rw-r--r-- | tools/idevicescreenshot.c | 2 |
6 files changed, 11 insertions, 21 deletions
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index 95c5694..8f5362c 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c | |||
| @@ -755,7 +755,7 @@ static void do_post_notification(const char *notification) | |||
| 755 | } | 755 | } |
| 756 | 756 | ||
| 757 | lockdownd_start_service(client, NP_SERVICE_NAME, &service); | 757 | lockdownd_start_service(client, NP_SERVICE_NAME, &service); |
| 758 | if (service->port) { | 758 | if (service && service->port) { |
| 759 | np_client_new(device, service, &np); | 759 | np_client_new(device, service, &np); |
| 760 | if (np) { | 760 | if (np) { |
| 761 | np_post_notification(np, notification); | 761 | np_post_notification(np, notification); |
| @@ -937,7 +937,7 @@ int main(int argc, char *argv[]) | |||
| 937 | /* start notification_proxy */ | 937 | /* start notification_proxy */ |
| 938 | np_client_t np = NULL; | 938 | np_client_t np = NULL; |
| 939 | ret = lockdownd_start_service(client, NP_SERVICE_NAME, &service); | 939 | ret = lockdownd_start_service(client, NP_SERVICE_NAME, &service); |
| 940 | if ((ret == LOCKDOWN_E_SUCCESS) && service->port) { | 940 | if ((ret == LOCKDOWN_E_SUCCESS) && service && service->port) { |
| 941 | np_client_new(device, service, &np); | 941 | np_client_new(device, service, &np); |
| 942 | np_set_notify_callback(np, notify_cb, NULL); | 942 | np_set_notify_callback(np, notify_cb, NULL); |
| 943 | const char *noties[5] = { | 943 | const char *noties[5] = { |
| @@ -952,11 +952,6 @@ int main(int argc, char *argv[]) | |||
| 952 | printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME); | 952 | printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME); |
| 953 | } | 953 | } |
| 954 | 954 | ||
| 955 | if (service) { | ||
| 956 | lockdownd_service_descriptor_free(service); | ||
| 957 | service = NULL; | ||
| 958 | } | ||
| 959 | |||
| 960 | afc_client_t afc = NULL; | 955 | afc_client_t afc = NULL; |
| 961 | if (cmd == CMD_BACKUP) { | 956 | if (cmd == CMD_BACKUP) { |
| 962 | /* start AFC, we need this for the lock file */ | 957 | /* start AFC, we need this for the lock file */ |
| @@ -975,7 +970,7 @@ int main(int argc, char *argv[]) | |||
| 975 | 970 | ||
| 976 | /* start mobilebackup service and retrieve port */ | 971 | /* start mobilebackup service and retrieve port */ |
| 977 | ret = lockdownd_start_service(client, MOBILEBACKUP_SERVICE_NAME, &service); | 972 | ret = lockdownd_start_service(client, MOBILEBACKUP_SERVICE_NAME, &service); |
| 978 | if ((ret == LOCKDOWN_E_SUCCESS) && service->port) { | 973 | if ((ret == LOCKDOWN_E_SUCCESS) && service && service->port) { |
| 979 | printf("Started \"%s\" service on port %d.\n", MOBILEBACKUP_SERVICE_NAME, service->port); | 974 | printf("Started \"%s\" service on port %d.\n", MOBILEBACKUP_SERVICE_NAME, service->port); |
| 980 | mobilebackup_client_new(device, service, &mobilebackup); | 975 | mobilebackup_client_new(device, service, &mobilebackup); |
| 981 | 976 | ||
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 0353c9b..d70a7ae 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c | |||
| @@ -489,7 +489,7 @@ static void do_post_notification(idevice_t device, const char *notification) | |||
| 489 | } | 489 | } |
| 490 | 490 | ||
| 491 | lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service); | 491 | lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service); |
| 492 | if (service->port) { | 492 | if (service && service->port) { |
| 493 | np_client_new(device, service, &np); | 493 | np_client_new(device, service, &np); |
| 494 | if (np) { | 494 | if (np) { |
| 495 | np_post_notification(np, notification); | 495 | np_post_notification(np, notification); |
| @@ -1557,7 +1557,7 @@ int main(int argc, char *argv[]) | |||
| 1557 | /* start notification_proxy */ | 1557 | /* start notification_proxy */ |
| 1558 | np_client_t np = NULL; | 1558 | np_client_t np = NULL; |
| 1559 | ret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service); | 1559 | ret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service); |
| 1560 | if ((ret == LOCKDOWN_E_SUCCESS) && service->port) { | 1560 | if ((ret == LOCKDOWN_E_SUCCESS) && service && service->port) { |
| 1561 | np_client_new(device, service, &np); | 1561 | np_client_new(device, service, &np); |
| 1562 | np_set_notify_callback(np, notify_cb, NULL); | 1562 | np_set_notify_callback(np, notify_cb, NULL); |
| 1563 | const char *noties[5] = { | 1563 | const char *noties[5] = { |
| @@ -1572,11 +1572,6 @@ int main(int argc, char *argv[]) | |||
| 1572 | printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME); | 1572 | printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME); |
| 1573 | } | 1573 | } |
| 1574 | 1574 | ||
| 1575 | if (service) { | ||
| 1576 | lockdownd_service_descriptor_free(service); | ||
| 1577 | service = NULL; | ||
| 1578 | } | ||
| 1579 | |||
| 1580 | afc_client_t afc = NULL; | 1575 | afc_client_t afc = NULL; |
| 1581 | if (cmd == CMD_BACKUP) { | 1576 | if (cmd == CMD_BACKUP) { |
| 1582 | /* start AFC, we need this for the lock file */ | 1577 | /* start AFC, we need this for the lock file */ |
| @@ -1596,7 +1591,7 @@ int main(int argc, char *argv[]) | |||
| 1596 | /* start mobilebackup service and retrieve port */ | 1591 | /* start mobilebackup service and retrieve port */ |
| 1597 | mobilebackup2_client_t mobilebackup2 = NULL; | 1592 | mobilebackup2_client_t mobilebackup2 = NULL; |
| 1598 | ret = lockdownd_start_service(lockdown, MOBILEBACKUP2_SERVICE_NAME, &service); | 1593 | ret = lockdownd_start_service(lockdown, MOBILEBACKUP2_SERVICE_NAME, &service); |
| 1599 | if ((ret == LOCKDOWN_E_SUCCESS) && service->port) { | 1594 | if ((ret == LOCKDOWN_E_SUCCESS) && service && service->port) { |
| 1600 | PRINT_VERBOSE(1, "Started \"%s\" service on port %d.\n", MOBILEBACKUP2_SERVICE_NAME, service->port); | 1595 | PRINT_VERBOSE(1, "Started \"%s\" service on port %d.\n", MOBILEBACKUP2_SERVICE_NAME, service->port); |
| 1601 | mobilebackup2_client_new(device, service, &mobilebackup2); | 1596 | mobilebackup2_client_new(device, service, &mobilebackup2); |
| 1602 | 1597 | ||
diff --git a/tools/idevicedebugserverproxy.c b/tools/idevicedebugserverproxy.c index 32438ad..3a25ebc 100644 --- a/tools/idevicedebugserverproxy.c +++ b/tools/idevicedebugserverproxy.c | |||
| @@ -297,7 +297,7 @@ int main(int argc, char *argv[]) | |||
| 297 | goto leave_cleanup; | 297 | goto leave_cleanup; |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | if ((lockdownd_start_service(lockdown, "com.apple.debugserver", &service) != LOCKDOWN_E_SUCCESS) || !service->port) { | 300 | if ((lockdownd_start_service(lockdown, "com.apple.debugserver", &service) != LOCKDOWN_E_SUCCESS) || !service || !service->port) { |
| 301 | fprintf(stderr, "Could not start com.apple.debugserver!\nPlease make sure to mount the developer disk image first.\n"); | 301 | fprintf(stderr, "Could not start com.apple.debugserver!\nPlease make sure to mount the developer disk image first.\n"); |
| 302 | result = EXIT_FAILURE; | 302 | result = EXIT_FAILURE; |
| 303 | goto leave_cleanup; | 303 | goto leave_cleanup; |
diff --git a/tools/idevicediagnostics.c b/tools/idevicediagnostics.c index 410d054..464df20 100644 --- a/tools/idevicediagnostics.c +++ b/tools/idevicediagnostics.c | |||
| @@ -188,7 +188,7 @@ int main(int argc, char **argv) | |||
| 188 | 188 | ||
| 189 | lockdownd_client_free(lockdown_client); | 189 | lockdownd_client_free(lockdown_client); |
| 190 | 190 | ||
| 191 | if ((ret == LOCKDOWN_E_SUCCESS) && (service->port > 0)) { | 191 | if ((ret == LOCKDOWN_E_SUCCESS) && service && (service->port > 0)) { |
| 192 | if (diagnostics_relay_client_new(device, service, &diagnostics_client) != DIAGNOSTICS_RELAY_E_SUCCESS) { | 192 | if (diagnostics_relay_client_new(device, service, &diagnostics_client) != DIAGNOSTICS_RELAY_E_SUCCESS) { |
| 193 | printf("Could not connect to diagnostics_relay!\n"); | 193 | printf("Could not connect to diagnostics_relay!\n"); |
| 194 | result = -1; | 194 | result = -1; |
diff --git a/tools/ideviceimagemounter.c b/tools/ideviceimagemounter.c index 57a2e27..e57d83a 100644 --- a/tools/ideviceimagemounter.c +++ b/tools/ideviceimagemounter.c | |||
| @@ -305,7 +305,7 @@ int main(int argc, char **argv) | |||
| 305 | 305 | ||
| 306 | lockdownd_start_service(lckd, "com.apple.mobile.mobile_image_mounter", &service); | 306 | lockdownd_start_service(lckd, "com.apple.mobile.mobile_image_mounter", &service); |
| 307 | 307 | ||
| 308 | if (service->port == 0) { | 308 | if (!service || service->port == 0) { |
| 309 | printf("ERROR: Could not start mobile_image_mounter service!\n"); | 309 | printf("ERROR: Could not start mobile_image_mounter service!\n"); |
| 310 | goto leave; | 310 | goto leave; |
| 311 | } | 311 | } |
| @@ -323,7 +323,7 @@ int main(int argc, char **argv) | |||
| 323 | if (!list_mode) { | 323 | if (!list_mode) { |
| 324 | struct stat fst; | 324 | struct stat fst; |
| 325 | if ((lockdownd_start_service(lckd, "com.apple.afc", &service) != | 325 | if ((lockdownd_start_service(lckd, "com.apple.afc", &service) != |
| 326 | LOCKDOWN_E_SUCCESS) || !service->port) { | 326 | LOCKDOWN_E_SUCCESS) || !service || !service->port) { |
| 327 | fprintf(stderr, "Could not start com.apple.afc!\n"); | 327 | fprintf(stderr, "Could not start com.apple.afc!\n"); |
| 328 | goto leave; | 328 | goto leave; |
| 329 | } | 329 | } |
diff --git a/tools/idevicescreenshot.c b/tools/idevicescreenshot.c index 23e7b41..d056dd0 100644 --- a/tools/idevicescreenshot.c +++ b/tools/idevicescreenshot.c | |||
| @@ -83,7 +83,7 @@ int main(int argc, char **argv) | |||
| 83 | 83 | ||
| 84 | lockdownd_start_service(lckd, "com.apple.mobile.screenshotr", &service); | 84 | lockdownd_start_service(lckd, "com.apple.mobile.screenshotr", &service); |
| 85 | lockdownd_client_free(lckd); | 85 | lockdownd_client_free(lckd); |
| 86 | if (service->port > 0) { | 86 | if (service && service->port > 0) { |
| 87 | if (screenshotr_client_new(device, service, &shotr) != SCREENSHOTR_E_SUCCESS) { | 87 | if (screenshotr_client_new(device, service, &shotr) != SCREENSHOTR_E_SUCCESS) { |
| 88 | printf("Could not connect to screenshotr!\n"); | 88 | printf("Could not connect to screenshotr!\n"); |
| 89 | } else { | 89 | } else { |
