diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lockdown.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/lockdown.c b/src/lockdown.c index e720b29..e3636d1 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
| @@ -1021,8 +1021,9 @@ ssize_t lockdownd_securead(gnutls_transport_ptr_t transport, char *buffer, size_ | |||
| 1021 | * | 1021 | * |
| 1022 | * @param control The lockdownd client | 1022 | * @param control The lockdownd client |
| 1023 | * @param service The name of the service to start | 1023 | * @param service The name of the service to start |
| 1024 | * | 1024 | * @param port The port number the service was started on |
| 1025 | * @return The port number the service was started on or 0 on failure. | 1025 | |
| 1026 | * @return an error code | ||
| 1026 | */ | 1027 | */ |
| 1027 | iphone_error_t iphone_lckd_start_service(iphone_lckd_client_t client, const char *service, int *port) | 1028 | iphone_error_t iphone_lckd_start_service(iphone_lckd_client_t client, const char *service, int *port) |
| 1028 | { | 1029 | { |
| @@ -1064,6 +1065,8 @@ iphone_error_t iphone_lckd_start_service(iphone_lckd_client_t client, const char | |||
| 1064 | if (!dict) | 1065 | if (!dict) |
| 1065 | return IPHONE_E_PLIST_ERROR; | 1066 | return IPHONE_E_PLIST_ERROR; |
| 1066 | 1067 | ||
| 1068 | ret = IPHONE_E_UNKNOWN_ERROR; | ||
| 1069 | |||
| 1067 | plist_t query_node = plist_find_node_by_string(dict, "StartService"); | 1070 | plist_t query_node = plist_find_node_by_string(dict, "StartService"); |
| 1068 | plist_t result_key_node = plist_get_next_sibling(query_node); | 1071 | plist_t result_key_node = plist_get_next_sibling(query_node); |
| 1069 | plist_t result_value_node = plist_get_next_sibling(result_key_node); | 1072 | plist_t result_value_node = plist_get_next_sibling(result_key_node); |
| @@ -1076,9 +1079,7 @@ iphone_error_t iphone_lckd_start_service(iphone_lckd_client_t client, const char | |||
| 1076 | plist_type port_key_type = plist_get_node_type(port_key_node); | 1079 | plist_type port_key_type = plist_get_node_type(port_key_node); |
| 1077 | plist_type port_value_type = plist_get_node_type(port_value_node); | 1080 | plist_type port_value_type = plist_get_node_type(port_value_node); |
| 1078 | 1081 | ||
| 1079 | if (result_key_type == PLIST_KEY && result_value_type == PLIST_STRING && port_key_type == PLIST_KEY | 1082 | if (result_key_type == PLIST_KEY && result_value_type == PLIST_STRING) { |
| 1080 | && port_value_type == PLIST_UINT) { | ||
| 1081 | |||
| 1082 | char *result_key = NULL; | 1083 | char *result_key = NULL; |
| 1083 | char *result_value = NULL; | 1084 | char *result_value = NULL; |
| 1084 | char *port_key = NULL; | 1085 | char *port_key = NULL; |
| @@ -1086,18 +1087,23 @@ iphone_error_t iphone_lckd_start_service(iphone_lckd_client_t client, const char | |||
| 1086 | 1087 | ||
| 1087 | plist_get_key_val(result_key_node, &result_key); | 1088 | plist_get_key_val(result_key_node, &result_key); |
| 1088 | plist_get_string_val(result_value_node, &result_value); | 1089 | plist_get_string_val(result_value_node, &result_value); |
| 1089 | plist_get_key_val(port_key_node, &port_key); | ||
| 1090 | plist_get_uint_val(port_value_node, &port_value); | ||
| 1091 | 1090 | ||
| 1092 | if (!strcmp(result_key, "Result") && !strcmp(result_value, "Success") && !strcmp(port_key, "Port")) { | 1091 | if (!strcmp(result_key, "Result") && !strcmp(result_value, "Failure")) { |
| 1093 | port_loc = port_value; | 1092 | ret = IPHONE_E_START_SERVICE_FAILED; |
| 1094 | ret = IPHONE_E_SUCCESS; | 1093 | } else { |
| 1095 | } | 1094 | if (port_key_type == PLIST_KEY && port_value_type == PLIST_UINT) { |
| 1095 | plist_get_key_val(port_key_node, &port_key); | ||
| 1096 | plist_get_uint_val(port_value_node, &port_value); | ||
| 1096 | 1097 | ||
| 1097 | if (port && ret == IPHONE_E_SUCCESS) | 1098 | if (!strcmp(result_key, "Result") && !strcmp(result_value, "Success") && !strcmp(port_key, "Port")) { |
| 1098 | *port = port_loc; | 1099 | port_loc = port_value; |
| 1099 | else | 1100 | ret = IPHONE_E_SUCCESS; |
| 1100 | ret = IPHONE_E_UNKNOWN_ERROR; | 1101 | } |
| 1102 | |||
| 1103 | if (port && ret == IPHONE_E_SUCCESS) | ||
| 1104 | *port = port_loc; | ||
| 1105 | } | ||
| 1106 | } | ||
| 1101 | } | 1107 | } |
| 1102 | 1108 | ||
| 1103 | plist_free(dict); | 1109 | plist_free(dict); |
