Skip to content

Commit feb9265

Browse files
committed
bootutil: loader: Add protected TLV size to image size check
The protected TLV section was not included in the size check of if an image could fit into a slot, which means that it was possible for file to be deemed as OK for storing but then failing due to insufficient flash space during the update Signed-off-by: Jamie McCrae <[email protected]>
1 parent 4d85e29 commit feb9265

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

boot/bootutil/src/loader.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,16 @@ boot_is_header_valid(const struct image_header *hdr, const struct flash_area *fa
880880
return false;
881881
}
882882

883+
#ifdef MCUBOOT_DECOMPRESS_IMAGES
884+
if (!MUST_DECOMPRESS(fap, BOOT_CURR_IMG(state), hdr)) {
885+
#else
886+
if (1) {
887+
#endif
888+
if (!boot_u32_safe_add(&size, size, hdr->ih_protect_tlv_size)) {
889+
return false;
890+
}
891+
}
892+
883893
if (size >= flash_area_get_size(fap)) {
884894
return false;
885895
}

0 commit comments

Comments
 (0)