Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: Thomas Altenbach <[email protected]>
- Loading branch information