mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
bootloader_support: fix issue in memory mapping for getting app descriptor
For getting secure_version field in anti rollback case, bootloader tries to map whole firmware partition but fails for cases where partition size is beyond available MMU free pages capacity. Fix here ensures to map only required length upto application descriptor size in firmware partition. Closes https://github.com/espressif/esp-idf/issues/5911
This commit is contained in:
parent
3e44ebd3d7
commit
0a0f7bbd6c
@ -242,13 +242,15 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t
|
|||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t *image = bootloader_mmap(partition->offset, partition->size);
|
const uint32_t app_desc_offset = sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t);
|
||||||
|
const uint32_t mmap_size = app_desc_offset + sizeof(esp_app_desc_t);
|
||||||
|
const uint8_t *image = bootloader_mmap(partition->offset, mmap_size);
|
||||||
if (image == NULL) {
|
if (image == NULL) {
|
||||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, partition->size);
|
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, mmap_size);
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(app_desc, image + sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t), sizeof(esp_app_desc_t));
|
memcpy(app_desc, image + app_desc_offset, sizeof(esp_app_desc_t));
|
||||||
bootloader_munmap(image);
|
bootloader_munmap(image);
|
||||||
|
|
||||||
if (app_desc->magic_word != ESP_APP_DESC_MAGIC_WORD) {
|
if (app_desc->magic_word != ESP_APP_DESC_MAGIC_WORD) {
|
||||||
|
Loading…
Reference in New Issue
Block a user