Skip to content

Commit

Permalink
[nrf fromlist] boot: bootutil: swap_scratch: Fix compressed image sec…
Browse files Browse the repository at this point in the history
…tor size check

Fixes an issue with compressed update support whereby it would wrong
continue to check all sector sizes and error due to the sector sizes
of the secondary slot being 0 until overflow

Upstream PR: mcu-tools/mcuboot#2085

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
  • Loading branch information
nordicjm committed Oct 7, 2024
1 parent 27c83ca commit 3a8108d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion boot/bootutil/src/swap_scratch.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,17 @@ boot_slots_compatible(struct boot_loader_state *state)
smaller = 1;
i++;
} else {
sz1 += boot_img_sector_size(state, BOOT_SECONDARY_SLOT, j);
size_t sector_size = boot_img_sector_size(state, BOOT_SECONDARY_SLOT, j);

#ifdef MCUBOOT_DECOMPRESS_IMAGES
if (sector_size == 0) {
/* Since this supports decompressed images, we can safely exit if slot1 is
* smaller than slot0.
*/
break;
}
#endif
sz1 += sector_size;
/* Guarantee that multiple sectors of the primary slot
* fit into the secondary slot.
*/
Expand Down

0 comments on commit 3a8108d

Please sign in to comment.