summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2021-08-12 23:38:59 +0200
committerGravatar Nikias Bassen2021-08-12 23:38:59 +0200
commit204782b2f34b3629f8c0cb953eb390f94a9a7582 (patch)
tree1493816d415f00be444d122fdb32a139d737851b
parent693bf2aa529e55deb8b9bd658c0d0e1dc4051e50 (diff)
downloadidevicerestore-204782b2f34b3629f8c0cb953eb390f94a9a7582.tar.gz
idevicerestore-204782b2f34b3629f8c0cb953eb390f94a9a7582.tar.bz2
img4: Check component entries in build identity for IMG4 tags (Img4PayloadType)
-rw-r--r--src/idevicerestore.c2
-rw-r--r--src/img4.c19
-rw-r--r--src/img4.h2
3 files changed, 19 insertions, 4 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index fa25ff4..9805f65 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -2115,7 +2115,7 @@ int get_preboard_manifest(struct idevicerestore_client_t* client, plist_t build_
}
plist_t local_manifest = NULL;
- int res = img4_create_local_manifest(request, &local_manifest);
+ int res = img4_create_local_manifest(request, build_identity, &local_manifest);
*manifest = local_manifest;
diff --git a/src/img4.c b/src/img4.c
index ae29bf3..222e35d 100644
--- a/src/img4.c
+++ b/src/img4.c
@@ -615,7 +615,7 @@ static void _manifest_write_component(unsigned char **p, unsigned int *length, c
*p += this_length + outer_length + inner_length;
}
-int img4_create_local_manifest(plist_t request, plist_t* manifest)
+int img4_create_local_manifest(plist_t request, plist_t build_identity, plist_t* manifest)
{
if (!request || !manifest) {
return -1;
@@ -655,6 +655,11 @@ int img4_create_local_manifest(plist_t request, plist_t* manifest)
/* create manifest properties set */
_manifest_write_key_value(&p, &length, "MANP", ASN1_SET | ASN1_CONSTRUCTED, tmp_, tmp_len);
+ plist_t component_manifest = NULL;
+ if (build_identity) {
+ component_manifest = plist_dict_get_item(build_identity, "Manifest");
+ }
+
/* now write the components */
plist_dict_iter iter = NULL;
plist_dict_new_iter(request, &iter);
@@ -663,7 +668,17 @@ int img4_create_local_manifest(plist_t request, plist_t* manifest)
do {
plist_dict_next_item(request, iter, &key, &val);
if (val && plist_get_node_type(val) == PLIST_DICT) {
- const char *comp = _img4_get_component_tag(key);
+ const char *comp = NULL;
+ /* check if component has Img4PayloadType */
+ if (component_manifest) {
+ plist_t img4_comp = plist_access_path(component_manifest, 3, key, "Info", "Img4PayloadType");
+ if (img4_comp) {
+ comp = plist_get_string_ptr(img4_comp, NULL);
+ }
+ }
+ if (!comp) {
+ comp = _img4_get_component_tag(key);
+ }
if (!comp) {
error("ERROR: %s: Unhandled component '%s' - can't create manifest\n", __func__, key);
free(iter);
diff --git a/src/img4.h b/src/img4.h
index ffbd57d..37dea56 100644
--- a/src/img4.h
+++ b/src/img4.h
@@ -27,7 +27,7 @@ extern "C" {
#endif
int img4_stitch_component(const char* component_name, const unsigned char* component_data, unsigned int component_size, const unsigned char* blob, unsigned int blob_size, unsigned char** img4_data, unsigned int *img4_size);
-int img4_create_local_manifest(plist_t request, plist_t* manifest);
+int img4_create_local_manifest(plist_t request, plist_t build_identity, plist_t* manifest);
#ifdef __cplusplus
}