Skip to content

Commit f9e096b

Browse files
committed
bootutil: In boot_swap_image add return check from boot_read_enc_key
Check return code instead of running loop over the key, to check if it has been read correctly. Signed-off-by: Dominik Ermel <[email protected]>
1 parent e09b501 commit f9e096b

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

boot/bootutil/src/loader.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,6 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
15881588
const struct flash_area *fap;
15891589
#ifdef MCUBOOT_ENC_IMAGES
15901590
uint8_t slot;
1591-
uint8_t i;
15921591
#endif
15931592
uint32_t size;
15941593
uint32_t copy_size;
@@ -1676,15 +1675,10 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
16761675
boot_enc_init(BOOT_CURR_ENC_SLOT(state, slot));
16771676

16781677
rc = boot_read_enc_key(fap, slot, bs);
1679-
assert(rc == 0);
1680-
1681-
for (i = 0; i < BOOT_ENC_KEY_SIZE; i++) {
1682-
if (bs->enckey[slot][i] != 0xff) {
1683-
break;
1684-
}
1685-
}
1686-
1687-
if (i != BOOT_ENC_KEY_SIZE) {
1678+
if (rc) {
1679+
BOOT_LOG_DBG("boot_swap_image: Failed loading key (%d, %d)",
1680+
image_index, slot);
1681+
} else {
16881682
boot_enc_set_key(BOOT_CURR_ENC_SLOT(state, slot), bs->enckey[slot]);
16891683
}
16901684
}

0 commit comments

Comments
 (0)