diff --git a/components/espcoredump/corefile/elf.py b/components/espcoredump/corefile/elf.py index 8ffa12b6cd..76c2c60a63 100644 --- a/components/espcoredump/corefile/elf.py +++ b/components/espcoredump/corefile/elf.py @@ -284,6 +284,13 @@ class ElfNoteSegment(ElfSegment): super(ElfNoteSegment, self).__init__(addr, data, flags) self.type = ElfFile.PT_NOTE self.note_secs = NoteSections.parse(self.data) + for note in self.note_secs: + # note.name should include a terminating NUL byte, plus possible + # padding + # + # (note: construct.PaddingString can't parse this if there + # are non-zero padding bytes after the NUL, it also parses those.) + note.name = note.name.split(b'\x00')[0] @staticmethod def _type_str(): # type: () -> str diff --git a/components/espcoredump/corefile/loader.py b/components/espcoredump/corefile/loader.py index 144a350826..8f9fce7442 100644 --- a/components/espcoredump/corefile/loader.py +++ b/components/espcoredump/corefile/loader.py @@ -261,7 +261,7 @@ class EspCoreDumpLoader(EspCoreDumpVersion): for seg in core_elf.note_segments: for note_sec in seg.note_secs: # Check for version info note - if note_sec.name == 'ESP_CORE_DUMP_INFO' \ + if note_sec.name == b'ESP_CORE_DUMP_INFO' \ and note_sec.type == ESPCoreDumpElfFile.PT_INFO \ and exe_name: exe_elf = ElfFile(exe_name)