Improve OTA boundary handling

This commit is contained in:
robert committed 2026-07-02 12:22:39 +03:00
1 parent 28cd3439dd
commit 9d3926a25a
3 files changed
+8 -2

No files matched your search

+3
View File
@@ -37,6 +37,9 @@ bool mg_ota_flash_write(const void *buf, size_t len, struct mg_flash *flash) {
bool ok = false;
if (s_size == 0) {
MG_ERROR(("OTA is not started, call mg_ota_begin()"));
} else if (s_addr + MG_ROUND_UP(len, flash->align) >
(char *) flash->start + flash->size) {
MG_ERROR(("Flash overflow: attempting to write past the flash boundary"));
} else {
size_t len_aligned_down = MG_ROUND_DOWN(len, flash->align);
if (len_aligned_down) ok = flash->write_fn(s_addr, buf, len_aligned_down);