diff options
| author | 2012-02-02 02:10:14 +0100 | |
|---|---|---|
| committer | 2012-02-02 02:10:14 +0100 | |
| commit | 3494d86d2195400c683a5a378fd90c2e8e7fc449 (patch) | |
| tree | 774043a95c0a3a64f59aaf76bc1e184c6601776e | |
| parent | 3913f910a840068ec34fd62f60b3bb78f7a9edd3 (diff) | |
| download | idevicerestore-3494d86d2195400c683a5a378fd90c2e8e7fc449.tar.gz idevicerestore-3494d86d2195400c683a5a378fd90c2e8e7fc449.tar.bz2 | |
main: check if device is supported by given ipsw build manifest
| -rw-r--r-- | src/idevicerestore.c | 29 | 
1 files changed, 29 insertions, 0 deletions
| 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; | 
