aboutsummaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
authormark9064 <30447455+mark9064@users.noreply.github.com>2024-02-13 01:20:46 +0000
committerJF <JF002@users.noreply.github.com>2024-02-14 19:12:08 +0100
commit93d7da16919a213404f00cbb26a630722b63d6f7 (patch)
tree2c1daff65898378d3d4c692c1584072e9e053101 /src/components
parentfa1af55a45fb277db71b6654ebe610a4d1bc7961 (diff)
Fix OOB flash write when DFU interrupted
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.
Diffstat (limited to 'src/components')
-rw-r--r--src/components/ble/DfuService.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/components/ble/DfuService.cpp b/src/components/ble/DfuService.cpp
index 1f06b69e..b3f2ff10 100644
--- a/src/components/ble/DfuService.cpp
+++ b/src/components/ble/DfuService.cpp
@@ -357,6 +357,8 @@ void DfuService::DfuImage::Init(size_t chunkSize, size_t totalSize, uint16_t exp
this->totalSize = totalSize;
this->expectedCrc = expectedCrc;
this->ready = true;
+ totalWriteIndex = 0;
+ bufferWriteIndex = 0;
}
void DfuService::DfuImage::Append(uint8_t* data, size_t size) {