diff options
author | Joshua Hill | 2010-06-08 10:18:58 +0200 |
---|---|---|
committer | Nikias Bassen | 2010-06-08 10:18:58 +0200 |
commit | 3e9a5359edd8c77d0af7509e326083ae62f7337d (patch) | |
tree | dd966d14d76886502d0f1a488295c981e52ec1c2 /src | |
parent | 2fb11ad1b97fe0d38da74794e5a1c59ffc5bcb6b (diff) | |
download | libimobiledevice-3e9a5359edd8c77d0af7509e326083ae62f7337d.tar.gz libimobiledevice-3e9a5359edd8c77d0af7509e326083ae62f7337d.tar.bz2 |
restored: Fixed crash when attempting to pass NULL values to restored_query_type
Diffstat (limited to 'src')
-rw-r--r-- | src/restore.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/restore.c b/src/restore.c index ab14c28..fd23d85 100644 --- a/src/restore.c +++ b/src/restore.c @@ -103,6 +103,7 @@ restored_error_t restored_client_free(restored_client_t client) { if (!client) return RESTORE_E_INVALID_ARG; + restored_error_t ret = RESTORE_E_UNKNOWN_ERROR; if (client->parent) { @@ -238,22 +239,29 @@ restored_error_t restored_query_type(restored_client_t client, char **type, uint client->info = dict; /* return the type if requested */ - if (type != NULL) { + if (type) { plist_t type_node = plist_dict_get_item(dict, "Type"); - plist_get_string_val(type_node, 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; + } } - debug_info("success with type %s", *type); - ret = RESTORE_E_SUCCESS; /* fetch the restore protocol version */ - plist_t version_node = plist_dict_get_item(dict, "RestoreProtocolVersion"); - if (version_node && version) { - plist_get_uint_val(version_node, version); - debug_info("restored protocol version %llu", *version); - ret = RESTORE_E_SUCCESS; - } else - ret = RESTORE_E_UNKNOWN_ERROR; - + if (version) { + plist_t version_node = plist_dict_get_item(dict, "RestoreProtocolVersion"); + 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; } return ret; |