From 204782b2f34b3629f8c0cb953eb390f94a9a7582 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Thu, 12 Aug 2021 23:38:59 +0200 Subject: img4: Check component entries in build identity for IMG4 tags (Img4PayloadType) --- src/img4.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/img4.c') 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); -- cgit v1.1-32-gdbae