Skip to content
Commit fbd2267e authored by Thomas Altenbach's avatar Thomas Altenbach Committed by Jamie
Browse files

boot: bootutil: Fix invalid last sector computation for swap-scratch



At the beginning of a swap-scratch upgrade, the index of the last sector
in the primary slot that need to be swapped is computed using the
'find_last_sector_idx' routine. However, if the primary slot is composed
of larger sectors than the secondary slots, this routine could return a
wrong sector index for the primary slot. The index might even be outside
the primary slot, which would lead to (at best) a simple failure of the
upgrade and at worst a corruption of the flash memory bricking the
device.

This commit fixes the issue by ensuring 'find_last_sector_idx' always
returns a valid sector index for the primary slot.

Signed-off-by: default avatarThomas Altenbach <thomas.altenbach@legrand.com>
parent 7724bcfd
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment