diff options
author | Nikias Bassen | 2013-03-14 01:42:50 +0100 |
---|---|---|
committer | Nikias Bassen | 2013-03-14 01:42:50 +0100 |
commit | 23abc8303b8cad9251cd4ea4b5fa5af28e5f0b24 (patch) | |
tree | 812ec33eb9f0dbcb827c01f99d98d3c372485040 /src | |
parent | f8052bed10e9d170aa0858a04fbeeb1a994ce307 (diff) | |
download | libimobiledevice-23abc8303b8cad9251cd4ea4b5fa5af28e5f0b24.tar.gz libimobiledevice-23abc8303b8cad9251cd4ea4b5fa5af28e5f0b24.tar.bz2 |
lockdown: only return service descriptor if StartService succeeds
Diffstat (limited to 'src')
-rw-r--r-- | src/lockdown.c | 16 |
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)) { |