Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

ftp/updater.c: Add checks for proper use #208

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion esp32/ftp/updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down
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