summaryrefslogtreecommitdiffstats
path: root/dev/ideviceclient.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-03-14 03:09:14 +0100
committerGravatar Nikias Bassen2013-03-14 03:09:14 +0100
commit4222bc1b880d6535462e3b5ba5431809a3c5fddc (patch)
treeb664bbdfe96d162930b2719ec920cd149684b0ed /dev/ideviceclient.c
parent23abc8303b8cad9251cd4ea4b5fa5af28e5f0b24 (diff)
downloadlibimobiledevice-4222bc1b880d6535462e3b5ba5431809a3c5fddc.tar.gz
libimobiledevice-4222bc1b880d6535462e3b5ba5431809a3c5fddc.tar.bz2
global: make sure to check service before checking service->port to prevent crashes
Diffstat (limited to 'dev/ideviceclient.c')
-rw-r--r--dev/ideviceclient.c17
1 files changed, 5 insertions, 12 deletions
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
49 np_client_t np; 49 np_client_t np;
50 50
51 lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &service); 51 lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &service);
52 if (service->port) { 52 if (service && service->port) {
53 printf("::::::::::::::: np was started ::::::::::::\n"); 53 printf("::::::::::::::: np was started ::::::::::::\n");
54 np_client_new(phone, service, &np); 54 np_client_new(phone, service, &np);
55 if (np) { 55 if (np) {
@@ -109,15 +109,10 @@ int main(int argc, char *argv[])
109 109
110 lockdownd_start_service(client, "com.apple.afc", &service); 110 lockdownd_start_service(client, "com.apple.afc", &service);
111 111
112 if (service->port) { 112 if (service && service->port) {
113 afc_client_t afc = NULL; 113 afc_client_t afc = NULL;
114 afc_client_new(phone, service, &afc); 114 afc_client_new(phone, service, &afc);
115 115
116 if (service) {
117 lockdownd_service_descriptor_free(service);
118 service = NULL;
119 }
120
121 if (afc) { 116 if (afc) {
122 service->port = 0; 117 service->port = 0;
123 service->ssl_enabled = 0; 118 service->ssl_enabled = 0;
@@ -129,11 +124,6 @@ int main(int argc, char *argv[])
129 printf("ERROR: Notification proxy could not be started.\n"); 124 printf("ERROR: Notification proxy could not be started.\n");
130 } 125 }
131 126
132 if (service) {
133 lockdownd_service_descriptor_free(service);
134 service = NULL;
135 }
136
137 if (gnp) { 127 if (gnp) {
138 const char *nspec[5] = { 128 const char *nspec[5] = {
139 NP_SYNC_CANCEL_REQUEST, 129 NP_SYNC_CANCEL_REQUEST,
@@ -266,6 +256,9 @@ int main(int argc, char *argv[])
266 } 256 }
267 257
268 afc_client_free(afc); 258 afc_client_free(afc);
259
260 lockdownd_service_descriptor_free(service);
261 service = NULL;
269 } else { 262 } else {
270 printf("Start service failure.\n"); 263 printf("Start service failure.\n");
271 } 264 }