InfiniTimeOrg / InfiniTime

Firmware for Pinetime smartwatch written in C++ and based on FreeRTOS
GNU General Public License v3.0
2.63k stars 901 forks source link

Fix OOB flash write when DFU interrupted #2020

Closed mark9064 closed 4 months ago

mark9064 commented 4 months ago

If a DFU is restarted, the write indices aren't reset causing the image to be written out of bounds. The CRC check prevents the faulty image from booting but LittleFS still gets nuked.

There are other issues with DFU if the central is acting maliciously, but this resolves a corruption encountered in normal usage. If a DFU fails for whatever reason (bad bluetooth signal, whatever), the user is likely to retry the update which will fail if they do not reboot first due to this issue.

github-actions[bot] commented 4 months ago
Build size and comparison to main: Section Size Difference
text 373224B -16B
data 940B 0B
bss 63516B 0B