Skip to content

Commit d06439e

Browse files
committed
Merge branch 'optimize/stop_do_ota_if_ota_size_overlength' into 'master'
optimize(ESPAT-2461): Stopped doing ota if ota bin oversize See merge request application/esp-at!1921
2 parents 8343f89 + cf5f5d2 commit d06439e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

components/at/src/at_ota_cmd.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,20 @@ bool esp_at_upgrade_process(at_ota_mode_t ota_mode, uint8_t *version, const char
505505
pStr += strlen("Content-Length: ");
506506
total_len = atoi((char*)pStr);
507507
ESP_AT_LOGI(TAG, "total_len=%d!\r\n", total_len);
508+
uint32_t partition_size = 0;
509+
if (upgrade_type == AT_UPGRADE_SYSTEM_FIRMWARE) {
510+
#if defined(CONFIG_BOOTLOADER_COMPRESSED_ENABLED) && defined(CONFIG_ENABLE_LEGACY_ESP_BOOTLOADER_PLUS_V2_SUPPORT)
511+
partition_size = handle.partition->size;
512+
#else
513+
partition_size = partition.size;
514+
#endif
515+
} else {
516+
partition_size = at_custom_partition->size;
517+
}
518+
if (total_len > partition_size) {
519+
ESP_AT_LOGE(TAG, "ota bin oversize, %d > %d", total_len, partition_size);
520+
goto OTA_ERROR;
521+
}
508522
pStr = (uint8_t*)strstr((char*)data_buffer, "\r\n\r\n");
509523
if (pStr) {
510524
pkg_body_start = true;

0 commit comments

Comments
 (0)