diff options
author | Nikias Bassen | 2013-03-14 03:09:14 +0100 |
---|---|---|
committer | Nikias Bassen | 2013-03-14 03:09:14 +0100 |
commit | 4222bc1b880d6535462e3b5ba5431809a3c5fddc (patch) | |
tree | b664bbdfe96d162930b2719ec920cd149684b0ed /dev | |
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 'dev')
-rw-r--r-- | dev/afccheck.c | 2 | ||||
-rw-r--r-- | dev/ideviceclient.c | 17 |
2 files changed, 6 insertions, 13 deletions
diff --git a/dev/afccheck.c b/dev/afccheck.c index ead0ca0..d7ee7d1 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -111,7 +111,7 @@ int main(int argc, char *argv[]) return 1; } - if (LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &service) && !service->port) { + if (LOCKDOWN_E_SUCCESS != lockdownd_start_service(client, "com.apple.afc", &service) || !service || !service->port) { lockdownd_client_free(client); idevice_free(phone); fprintf(stderr, "Something went wrong when starting AFC."); diff --git a/dev/ideviceclient.c b/dev/ideviceclient.c index c8635d8..778f20e 100644 --- a/dev/ideviceclient.c +++ b/dev/ideviceclient.c @@ -49,7 +49,7 @@ static void perform_notification(idevice_t phone, lockdownd_client_t client, con np_client_t np; lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &service); - if (service->port) { + if (service && service->port) { printf("::::::::::::::: np was started ::::::::::::\n"); np_client_new(phone, service, &np); if (np) { @@ -109,15 +109,10 @@ int main(int argc, char *argv[]) lockdownd_start_service(client, "com.apple.afc", &service); - if (service->port) { + if (service && service->port) { afc_client_t afc = NULL; afc_client_new(phone, service, &afc); - if (service) { - lockdownd_service_descriptor_free(service); - service = NULL; - } - if (afc) { service->port = 0; service->ssl_enabled = 0; @@ -129,11 +124,6 @@ int main(int argc, char *argv[]) printf("ERROR: Notification proxy could not be started.\n"); } - if (service) { - lockdownd_service_descriptor_free(service); - service = NULL; - } - if (gnp) { const char *nspec[5] = { NP_SYNC_CANCEL_REQUEST, @@ -266,6 +256,9 @@ int main(int argc, char *argv[]) } afc_client_free(afc); + + lockdownd_service_descriptor_free(service); + service = NULL; } else { printf("Start service failure.\n"); } |