Skip to content

Commit 8c814cb

Browse files
committed
[nrf fromlist] 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 Upstream PR: mcu-tools/mcuboot#2085 Signed-off-by: Jamie McCrae <[email protected]>
1 parent b245ccd commit 8c814cb

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
@@ -203,7 +203,17 @@ boot_slots_compatible(struct boot_loader_state *state)
203203
smaller = 1;
204204
i++;
205205
} else {
206-
sz1 += boot_img_sector_size(state, BOOT_SECONDARY_SLOT, j);
206+
size_t sector_size = boot_img_sector_size(state, BOOT_SECONDARY_SLOT, j);
207+
208+
#ifdef MCUBOOT_DECOMPRESS_IMAGES
209+
if (sector_size == 0) {
210+
/* Since this supports decompressed images, we can safely exit if slot1 is
211+
* smaller than slot0.
212+
*/
213+
break;
214+
}
215+
#endif
216+
sz1 += sector_size;
207217
/* Guarantee that multiple sectors of the primary slot
208218
* fit into the secondary slot.
209219
*/

0 commit comments

Comments
 (0)