Skip to content

Commit

Permalink
bootutil: loader: Add protected TLV size to image size check
Browse files Browse the repository at this point in the history
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 <jamie.mccrae@nordicsemi.no>
  • Loading branch information
nordicjm committed Aug 23, 2024
1 parent 4a95b38 commit cf0b103
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,16 @@ boot_is_header_valid(const struct image_header *hdr, const struct flash_area *fa
return false;
}

#ifdef MCUBOOT_DECOMPRESS_IMAGES
if (!MUST_DECOMPRESS(fap, BOOT_CURR_IMG(state), hdr)) {
#else
if (1) {
#endif
if (!boot_u32_safe_add(&size, size, hdr->ih_protect_tlv_size)) {
return false;
}
}

if (size >= flash_area_get_size(fap)) {
return false;
}
Expand Down

0 comments on commit cf0b103

Please sign in to comment.