fix(coredump): fix buffer overflow inside esp_core_dump_get_summary

Closes https://github.com/espressif/esp-idf/issues/13754
This commit is contained in:
Erhan Kurubas 2024-05-07 00:55:17 +02:00
parent 94fc3630f5
commit 8e524d708c
3 changed files with 10 additions and 1 deletions

View File

@ -933,7 +933,7 @@ static void elf_parse_version_info(esp_core_dump_summary_t *summary, void *data)
{
core_dump_elf_version_info_t *version = (core_dump_elf_version_info_t *)data;
summary->core_dump_version = version->version;
memcpy(summary->app_elf_sha256, version->app_elf_sha256, ELF_APP_SHA256_SIZE);
memcpy(summary->app_elf_sha256, version->app_elf_sha256, sizeof(summary->app_elf_sha256));
ESP_COREDUMP_LOGD("Core dump version 0x%x", summary->core_dump_version);
ESP_COREDUMP_LOGD("App ELF SHA2 %s", (char *)summary->app_elf_sha256);
}

View File

@ -285,6 +285,11 @@ void test_coredump_summary(void)
if (err == ESP_OK) {
printf("App ELF file SHA256: %s\n", (char *)summary->app_elf_sha256);
printf("Crashed task: %s\n", summary->exc_task);
#if __XTENSA__
printf("Exception cause: %ld\n", summary->ex_info.exc_cause);
#else
printf("Exception cause: %ld\n", summary->ex_info.mcause);
#endif
char panic_reason[200];
err = esp_core_dump_get_panic_reason(panic_reason, sizeof(panic_reason));
if (err == ESP_OK) {

View File

@ -1002,6 +1002,10 @@ def _test_coredump_summary(dut: PanicTestDut, flash_encrypted: bool, coredump_en
return
dut.expect_elf_sha256('App ELF file SHA256: ')
dut.expect_exact('Crashed task: main')
if dut.is_xtensa:
dut.expect_exact('Exception cause: 29')
else:
dut.expect_exact('Exception cause: 7')
dut.expect(PANIC_ABORT_PREFIX + r'assert failed:[\s\w()]*?\s[.\w/]*\.(?:c|cpp|h|hpp):\d.*$')