From 3e46a73964cac3958a748f06470b924c402a269f Mon Sep 17 00:00:00 2001 From: "nilesh.kale" Date: Tue, 20 May 2025 10:56:44 +0530 Subject: [PATCH] fix(esp_https_ota): Check and handle missing image length in OTA HTTP response --- components/esp_https_ota/src/esp_https_ota.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/esp_https_ota/src/esp_https_ota.c b/components/esp_https_ota/src/esp_https_ota.c index 2757121378..7dd2ee40a5 100644 --- a/components/esp_https_ota/src/esp_https_ota.c +++ b/components/esp_https_ota/src/esp_https_ota.c @@ -379,6 +379,11 @@ esp_err_t esp_https_ota_begin(const esp_https_ota_config_t *ota_config, esp_http } https_ota_handle->image_length = esp_http_client_get_content_length(https_ota_handle->http_client); + if (https_ota_handle->image_length == -1) { + ESP_LOGE(TAG, "Failed to get image length from http response"); + err = ESP_FAIL; + goto http_cleanup; + } #if CONFIG_ESP_HTTPS_OTA_DECRYPT_CB /* In case of pre ecnrypted OTA, actual image size of OTA binary includes header size * which stored in variable enc_img_header_size */