Skip to content

Commit 05181a8

Browse files
authored
[libunwind] Fix wrong end argument passed to decodeEHHdr() (#68813)
All but one callsite were actually passing start+length arguments. This should not have any functional change since the end argument is almost always ignored. I noticed this while debugging some incorrect error messages being printed while running the testsuite baremetal (using binaries that did not have a valid eh_frame_hdr section): the tests print `libunwind: unsupported .eh_frame_hdr version: 20 at https://github.com/arichardson/upstream-llvm-project/commit/8000d308146ebf49cb364cb600e28a0a42e22c83` because libunwind is reading nonsense data for .eh_frame_hdr.
1 parent 3255761 commit 05181a8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

libunwind/src/AddressSpace.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ static bool checkForUnwindInfoSegment(const Elf_Phdr *phdr, size_t image_base,
414414
cbdata->sects->dwarf_index_section = eh_frame_hdr_start;
415415
cbdata->sects->dwarf_index_section_length = phdr->p_memsz;
416416
if (EHHeaderParser<LocalAddressSpace>::decodeEHHdr(
417-
*cbdata->addressSpace, eh_frame_hdr_start, phdr->p_memsz,
418-
hdrInfo)) {
417+
*cbdata->addressSpace, eh_frame_hdr_start,
418+
eh_frame_hdr_start + phdr->p_memsz, hdrInfo)) {
419419
// .eh_frame_hdr records the start of .eh_frame, but not its size.
420420
// Rely on a zero terminator to find the end of the section.
421421
cbdata->sects->dwarf_section = hdrInfo.eh_frame_ptr;
@@ -638,7 +638,8 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
638638
info.dwarf_index_section_length = SIZE_MAX;
639639
EHHeaderParser<LocalAddressSpace>::EHHeaderInfo hdrInfo;
640640
if (!EHHeaderParser<LocalAddressSpace>::decodeEHHdr(
641-
*this, info.dwarf_index_section, info.dwarf_index_section_length,
641+
*this, info.dwarf_index_section,
642+
info.dwarf_index_section + info.dwarf_index_section_length,
642643
hdrInfo)) {
643644
return false;
644645
}

0 commit comments

Comments
 (0)