summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-09-24 02:15:43 +0200
committerGravatar Nikias Bassen2013-09-24 02:15:43 +0200
commita1fc3913b30a5b078ce73228e3a5e96416fb8059 (patch)
tree72e68bf0a629205ad0e8ee321ca114ba652a1b61 /src
parent959a2a203577b5505468fbaa10e6cd54f497213b (diff)
downloadlibimobiledevice-a1fc3913b30a5b078ce73228e3a5e96416fb8059.tar.gz
libimobiledevice-a1fc3913b30a5b078ce73228e3a5e96416fb8059.tar.bz2
restore: improve restored_query_type result checking
Diffstat (limited to 'src')
-rw-r--r--src/restore.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/restore.c b/src/restore.c
index 85009e4..a7f07f2 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -232,20 +232,20 @@ restored_error_t restored_query_type(restored_client_t client, char **type, uint
return ret;
ret = RESTORE_E_UNKNOWN_ERROR;
- if (restored_check_result(dict) == RESULT_SUCCESS) {
+ plist_t type_node = plist_dict_get_item(dict, "Type");
+ if (type_node && (plist_get_node_type(type_node) == PLIST_STRING)) {
+ char* typestr = NULL;
+
/* save our device information info */
client->info = dict;
-
+
+ plist_get_string_val(type_node, &typestr);
+ debug_info("success with type %s", typestr);
/* return the type if requested */
if (type) {
- plist_t type_node = plist_dict_get_item(dict, "Type");
- if (type_node && PLIST_STRING == plist_get_node_type(type_node)) {
- plist_get_string_val(type_node, type);
- debug_info("success with type %s", *type);
- ret = RESTORE_E_SUCCESS;
- } else {
- return RESTORE_E_UNKNOWN_ERROR;
- }
+ *type = typestr;
+ } else {
+ free(typestr);
}
/* fetch the restore protocol version */
@@ -254,12 +254,15 @@ restored_error_t restored_query_type(restored_client_t client, char **type, uint
if (version_node && PLIST_UINT == plist_get_node_type(version_node)) {
plist_get_uint_val(version_node, version);
debug_info("restored protocol version %llu", *version);
- ret = RESTORE_E_SUCCESS;
} else {
return RESTORE_E_UNKNOWN_ERROR;
}
}
ret = RESTORE_E_SUCCESS;
+ } else {
+ debug_info("hmm. QueryType response does not contain a type?!\n");
+ debug_plist(dict);
+ plist_free(dict);
}
return ret;