diff options
| author | 2013-03-14 03:09:14 +0100 | |
|---|---|---|
| committer | 2013-03-14 03:09:14 +0100 | |
| commit | 4222bc1b880d6535462e3b5ba5431809a3c5fddc (patch) | |
| tree | b664bbdfe96d162930b2719ec920cd149684b0ed /tools/idevicebackup.c | |
| 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/idevicebackup.c')
| -rw-r--r-- | tools/idevicebackup.c | 11 |
1 files changed, 3 insertions, 8 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 | ||
