Support loading COSWID when only one role has been set

CBOR supports removing the array for only one base element, which the python
uSWID tools now support; allow parsing this in fwupd.
This commit is contained in:
Richard Hughes 2022-10-23 10:35:15 +01:00
parent 7ea89eea62
commit 5a2ef166ee

View File

@ -135,6 +135,10 @@ fu_coswid_firmware_parse_entity(FuCoswidFirmware *self, cbor_item_t *item, GErro
} else if (tag_id == FU_COSWID_TAG_REG_ID) { } else if (tag_id == FU_COSWID_TAG_REG_ID) {
entity->regid = fu_coswid_firmware_strndup(pairs[i].value); entity->regid = fu_coswid_firmware_strndup(pairs[i].value);
} else if (tag_id == FU_COSWID_TAG_ROLE) { } else if (tag_id == FU_COSWID_TAG_ROLE) {
if (cbor_isa_uint(pairs[i].value)) {
FuCoswidEntityRole role = cbor_get_uint8(pairs[i].value);
entity->roles[entity_role_cnt++] = role;
}
for (guint j = 0; j < cbor_array_size(pairs[i].value); j++) { for (guint j = 0; j < cbor_array_size(pairs[i].value); j++) {
g_autoptr(cbor_item_t) value = cbor_array_get(pairs[i].value, j); g_autoptr(cbor_item_t) value = cbor_array_get(pairs[i].value, j);
FuCoswidEntityRole role = cbor_get_uint8(value); FuCoswidEntityRole role = cbor_get_uint8(value);