boot: bootutil: Fix scratch trailer overwritten if image trailer is large
When using swap-scratch and the image trailer doesn't fit in a single
sector, some padding might be necessary between the end of the firmware
data and the beginning of the image trailer. Indeed, when the trailer
fit in a single sector, it is guaranteed that when copying the firmware
data from this sector to the scratch area, it won't overwrite the
trailer in the scratch trailer since that trailer is always smaller the
image trailer.
However, when the trailer is larger than a single sector, the sector
containing the last part of the firmware data might only contain a very
small part of the trailer. There is no more guarantee that the scratch
trailer won't get overwritten when copying that sector to the sratch
area. Therefore, a check must be added to handle that case.
Signed-off-by:
Thomas Altenbach <thomas.altenbach@legrand.com>
Loading
Please sign in to comment