summaryrefslogtreecommitdiffstats
path: root/src/ipsw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipsw.c')
-rw-r--r--src/ipsw.c50
1 files changed, 9 insertions, 41 deletions
diff --git a/src/ipsw.c b/src/ipsw.c
index 2965100..7d3c45f 100644
--- a/src/ipsw.c
+++ b/src/ipsw.c
@@ -278,69 +278,37 @@ int ipsw_get_latest_fw(plist_t version_data, const char* product, char** fwurl,
memset(sha1buf, '\0', 20);
}
- plist_t n1 = plist_access_path(version_data, 2, "MobileDeviceMajorVersionsByProductType", product);
- if (!n1 || (plist_dict_get_size(n1) == 0)) {
- error("%s: ERROR: Can't find MobileDeviceMajorVersionsByProductType/%s dict in version data\n", __func__, product);
+ plist_t n1 = plist_dict_get_item(version_data, "MobileDeviceSoftwareVersionsByVersion");
+ if (!n1) {
+ error("%s: ERROR: Can't find MobileDeviceSoftwareVersionsByVersion dict in version data\n", __func__);
return -1;
}
- char* strval = NULL;
- plist_t n2 = plist_dict_get_item(n1, "SameAs");
- if (n2) {
- plist_get_string_val(n2, &strval);
- }
- if (strval) {
- n1 = plist_access_path(version_data, 2, "MobileDeviceMajorVersionsByProductType", strval);
- free(strval);
- strval = NULL;
- if (!n1 || (plist_dict_get_size(n1) == 0)) {
- error("%s: ERROR: Can't find MobileDeviceMajorVersionsByProductType/%s dict in version data\n", __func__, product);
- return -1;
- }
- }
-
plist_dict_iter iter = NULL;
plist_dict_new_iter(n1, &iter);
if (!iter) {
error("%s: ERROR: Can't get dict iter\n", __func__);
return -1;
}
- n2 = NULL;
char* key = NULL;
+ long long unsigned int major = 0;
plist_t val = NULL;
do {
plist_dict_next_item(n1, iter, &key, &val);
if (key) {
- n2 = val;
+ long long unsigned int v = strtoull(key, NULL, 10);
+ if (v > major)
+ major = v;
free(key);
}
} while (val);
free(iter);
- if (!n2) {
- error("%s: ERROR: Can't get last node?!\n", __func__);
- return -1;
- }
-
- uint64_t major = 0;
- if (plist_get_node_type(n2) == PLIST_ARRAY) {
- uint32_t sz = plist_array_get_size(n2);
- plist_t n3 = plist_array_get_item(n2, sz-1);
- plist_get_uint_val(n3, &major);
- } else {
- plist_get_uint_val(n2, &major);
- }
-
if (major == 0) {
error("%s: ERROR: Can't find major version?!\n", __func__);
return -1;
}
- if (major == 11) {
- /* FIXME workaround as with the iOS 7 release, Apple broke their own XML structure and logic */
- major = 12;
- }
-
char majstr[32]; // should be enough for a uint64_t value
sprintf(majstr, FMT_qu, (long long unsigned int)major);
n1 = plist_access_path(version_data, 7, "MobileDeviceSoftwareVersionsByVersion", majstr, "MobileDeviceSoftwareVersions", product, "Unknown", "Universal", "Restore");
@@ -355,13 +323,13 @@ int ipsw_get_latest_fw(plist_t version_data, const char* product, char** fwurl,
}
}
- n2 = plist_dict_get_item(n1, "BuildVersion");
+ plist_t n2 = plist_dict_get_item(n1, "BuildVersion");
if (!n2 || (plist_get_node_type(n2) != PLIST_STRING)) {
error("%s: ERROR: Can't get build version node?!\n", __func__);
return -1;
}
- strval = NULL;
+ char* strval = NULL;
plist_get_string_val(n2, &strval);
n1 = plist_access_path(version_data, 5, "MobileDeviceSoftwareVersionsByVersion", majstr, "MobileDeviceSoftwareVersions", product, strval);