Commit feb9265f authored by Jamie McCrae's avatar Jamie McCrae Committed by Jamie
Browse files

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: default avatarJamie McCrae <jamie.mccrae@nordicsemi.no>
parent 4d85e29f
Loading
Loading
Loading
Loading
+10 −0
Changes for boot/bootutil/src/loader.c: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -880,6 +880,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;
    }