summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-03-14 01:42:50 +0100
committerGravatar Nikias Bassen2013-03-14 01:42:50 +0100
commit23abc8303b8cad9251cd4ea4b5fa5af28e5f0b24 (patch)
tree812ec33eb9f0dbcb827c01f99d98d3c372485040
parentf8052bed10e9d170aa0858a04fbeeb1a994ce307 (diff)
downloadlibimobiledevice-23abc8303b8cad9251cd4ea4b5fa5af28e5f0b24.tar.gz
libimobiledevice-23abc8303b8cad9251cd4ea4b5fa5af28e5f0b24.tar.bz2
lockdown: only return service descriptor if StartService succeeds
-rw-r--r--src/lockdown.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index df1f60f..f78a78d 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -1512,6 +1512,12 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char
if (!client || !identifier || !service)
return LOCKDOWN_E_INVALID_ARG;
+ if (*service) {
+ // reset fields if service descriptor is reused
+ (*service)->port = 0;
+ (*service)->ssl_enabled = 0;
+ }
+
char *host_id = NULL;
userpref_get_host_id(&host_id);
if (!host_id)
@@ -1547,13 +1553,13 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char
if (!dict)
return LOCKDOWN_E_PLIST_ERROR;
- if (*service == NULL)
- *service = (lockdownd_service_descriptor_t)malloc(sizeof(struct lockdownd_service_descriptor));
- (*service)->port = 0;
- (*service)->ssl_enabled = 0;
-
ret = LOCKDOWN_E_UNKNOWN_ERROR;
if (lockdown_check_result(dict, "StartService") == RESULT_SUCCESS) {
+ if (*service == NULL)
+ *service = (lockdownd_service_descriptor_t)malloc(sizeof(struct lockdownd_service_descriptor));
+ (*service)->port = 0;
+ (*service)->ssl_enabled = 0;
+
/* read service port number */
plist_t node = plist_dict_get_item(dict, "Port");
if (node && (plist_get_node_type(node) == PLIST_UINT)) {