Skip to content

Commit 08a71d1

Browse files
committed
boot: bootutil: swap_scratch: Fix compressed image sector 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 Signed-off-by: Jamie McCrae <[email protected]>
1 parent d69933c commit 08a71d1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

boot/bootutil/src/swap_scratch.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,17 @@ boot_slots_compatible(struct boot_loader_state *state)
191191
smaller = 1;
192192
i++;
193193
} else {
194-
sz1 += boot_img_sector_size(state, BOOT_SECONDARY_SLOT, j);
194+
size_t sector_size = boot_img_sector_size(state, BOOT_SECONDARY_SLOT, j);
195+
196+
#ifdef MCUBOOT_DECOMPRESS_IMAGES
197+
if (sector_size == 0) {
198+
/* Since this supports decompressed images, we can safely exit if slot1 is
199+
* smaller than slot0.
200+
*/
201+
break;
202+
}
203+
#endif
204+
sz1 += sector_size;
195205
/* Guarantee that multiple sectors of the primary slot
196206
* fit into the secondary slot.
197207
*/

0 commit comments

Comments
 (0)