From 3494d86d2195400c683a5a378fd90c2e8e7fc449 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Thu, 2 Feb 2012 02:10:14 +0100 Subject: main: check if device is supported by given ipsw build manifest --- src/idevicerestore.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/idevicerestore.c') diff --git a/src/idevicerestore.c b/src/idevicerestore.c index 13966d0..4965ccf 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -162,6 +162,12 @@ int main(int argc, char* argv[]) { return -1; } + /* check if device type is supported by the given build manifest */ + if (build_manifest_check_compatibility(buildmanifest, client->device->product) < 0) { + error("ERROR: could not make sure this firmware is suitable for the current device. refusing to continue.\n"); + return -1; + } + /* print iOS information from the manifest */ build_manifest_get_version_information(buildmanifest, &client->version, &client->build); @@ -665,6 +671,29 @@ int ipsw_get_component_by_path(const char* ipsw, plist_t tss, const char* path, return 0; } +int build_manifest_check_compatibility(plist_t build_manifest, const char* product) { + int res = -1; + plist_t node = plist_dict_get_item(build_manifest, "SupportedProductTypes"); + if (!node || (plist_get_node_type(node) != PLIST_ARRAY)) { + debug("%s: ERROR: SupportedProductTypes key missing\n", __func__); + return -1; + } + uint32_t pc = plist_array_get_size(node); + uint32_t i; + for (i = 0; i < pc; i++) { + plist_t prod = plist_array_get_item(node, i); + if (plist_get_node_type(prod) == PLIST_STRING) { + char *val = NULL; + plist_get_string_val(prod, &val); + if (val && (strcmp(val, product) == 0)) { + res = 0; + break; + } + } + } + return res; +} + void build_manifest_get_version_information(plist_t build_manifest, char** product_version, char** product_build) { plist_t node = NULL; *product_version = NULL; -- cgit v1.1-32-gdbae