From 284f9c6ee88476812be26b5c58d3efd09ccaa79b Mon Sep 17 00:00:00 2001 From: robert h Date: Thu, 6 Sep 2018 15:10:52 +0200 Subject: [PATCH] ftp/updater.x: Add checks for proper use. --- esp32/ftp/updater.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/esp32/ftp/updater.c b/esp32/ftp/updater.c index 41e9629188..29b57950bc 100644 --- a/esp32/ftp/updater.c +++ b/esp32/ftp/updater.c @@ -123,6 +123,14 @@ bool updater_write (uint8_t *buf, uint32_t len) { // the actual writing into flash, not-encrypted, // because it already came encrypted from OTA server + if (updater_data.offset == 0) { + ESP_LOGE(TAG, "OTA start not called\n"); + return false; + } + if ((boot_info.size + len) > IMG_SIZE) { + ESP_LOGE(TAG, "OTA write attempt > partition\n"); + return false; + } if (ESP_OK != updater_spi_flash_write(updater_data.offset, (void *)buf, len, false)) { ESP_LOGE(TAG, "SPI flash write failed\n"); return false; @@ -132,7 +140,8 @@ bool updater_write (uint8_t *buf, uint32_t len) { updater_data.current_chunk += len; boot_info.size += len; - if (updater_data.current_chunk >= SPI_FLASH_SEC_SIZE) { + if ((updater_data.current_chunk >= SPI_FLASH_SEC_SIZE) && + (boot_info.size <= (IMG_SIZE - SPI_FLASH_SEC_SIZE))) { updater_data.current_chunk -= SPI_FLASH_SEC_SIZE; // erase the next sector if (ESP_OK != spi_flash_erase_sector((updater_data.offset + SPI_FLASH_SEC_SIZE) / SPI_FLASH_SEC_SIZE)) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy