summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2021-10-25 23:55:33 +0200
committerGravatar Nikias Bassen2021-10-25 23:55:33 +0200
commit968f9e1e24d05667a30fa2b51261d9032cd009ce (patch)
tree9a320e4364ac126b2c413c9e15b55cdfe988cdd3
parent03c3cf8f8359f99f47fe5c3c9ec78bf48b377d82 (diff)
downloadidevicerestore-968f9e1e24d05667a30fa2b51261d9032cd009ce.tar.gz
idevicerestore-968f9e1e24d05667a30fa2b51261d9032cd009ce.tar.bz2
ipsw: Migrate to ipsw.me v4 API
-rw-r--r--src/ipsw.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/ipsw.c b/src/ipsw.c
index f3b7f57..844328c 100644
--- a/src/ipsw.c
+++ b/src/ipsw.c
@@ -735,6 +735,7 @@ int ipsw_get_signed_firmwares(const char* product, plist_t* firmwares)
plist_t dict = NULL;
plist_t node = NULL;
plist_t fws = NULL;
+ const char* product_type = NULL;
uint32_t count = 0;
uint32_t i = 0;
@@ -743,7 +744,7 @@ int ipsw_get_signed_firmwares(const char* product, plist_t* firmwares)
}
*firmwares = NULL;
- snprintf(url, sizeof(url), "https://api.ipsw.me/v3/device/%s", product);
+ snprintf(url, sizeof(url), "https://api.ipsw.me/v4/device/%s", product);
if (download_to_buffer(url, &jdata, &jsize) < 0) {
error("ERROR: Download from %s failed.\n", url);
@@ -757,15 +758,21 @@ int ipsw_get_signed_firmwares(const char* product, plist_t* firmwares)
return -1;
}
- node = plist_dict_get_item(dict, product);
- if (!node || plist_get_node_type(node) != PLIST_DICT) {
- error("ERROR: Unexpected json data returned?!\n");
+ node = plist_dict_get_item(dict, "identifier");
+ if (!node || plist_get_node_type(node) != PLIST_STRING) {
+ error("ERROR: Unexpected json data returned - missing 'identifier'\n");
plist_free(dict);
return -1;
}
- fws = plist_dict_get_item(node, "firmwares");
+ product_type = plist_get_string_ptr(node, NULL);
+ if (!product_type || strcmp(product_type, product) != 0) {
+ error("ERROR: Unexpected json data returned - failed to read identifier\n");
+ plist_free(dict);
+ return -1;
+ }
+ fws = plist_dict_get_item(dict, "firmwares");
if (!fws || plist_get_node_type(fws) != PLIST_ARRAY) {
- error("ERROR: Unexpected json data returned?!\n");
+ error("ERROR: Unexpected json data returned - missing 'firmwares'\n");
plist_free(dict);
return -1;
}