mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-03 13:28:44 +00:00
Improve OTA boundary handling
This commit is contained in:
1 parent
28cd3439dd
commit
9d3926a25a
3 files changed
+8
-2
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user