Skip to content

Commit 0ccce2f

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 <dominik.ermel@nordicsemi.no>
1 parent 32b3c18 commit 0ccce2f

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
@@ -1105,7 +1105,6 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
11051105
const struct flash_area *fap;
11061106
#ifdef MCUBOOT_ENC_IMAGES
11071107
uint8_t slot;
1108-
uint8_t i;
11091108
#endif
11101109
uint32_t size;
11111110
uint32_t copy_size;
@@ -1193,15 +1192,10 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
11931192
boot_enc_init(BOOT_CURR_ENC_SLOT(state, slot));
11941193

11951194
rc = boot_read_enc_key(fap, slot, bs);
1196-
assert(rc == 0);
1197-
1198-
for (i = 0; i < BOOT_ENC_KEY_SIZE; i++) {
1199-
if (bs->enckey[slot][i] != 0xff) {
1200-
break;
1201-
}
1202-
}
1203-
1204-
if (i != BOOT_ENC_KEY_SIZE) {
1195+
if (rc) {
1196+
BOOT_LOG_DBG("boot_swap_image: Failed loading key (%d, %d)",
1197+
image_index, slot);
1198+
} else {
12051199
boot_enc_set_key(BOOT_CURR_ENC_SLOT(state, slot), bs->enckey[slot]);
12061200
}
12071201
}

0 commit comments

Comments
 (0)