Skip to content

Commit

Permalink
Prevent infinite recursion in the DWARF parser
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoticgd committed Oct 31, 2024
1 parent 43cc707 commit 92d81b5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ccc/dwarf_section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ Result<std::optional<DIE>> DIE::sibling() const
CCC_RETURN_IF_ERROR(attribute);

if (attribute->attribute == AT_sibling && attribute->value.form() == FORM_REF) {
// Prevent infinite recursion if the file contains a cycle.
CCC_CHECK(attribute->value.reference() > m_offset,
"Sibling attribute of DIE at 0x%x points backwards.", m_offset);
return DIE::parse(m_debug, attribute->value.reference(), m_importer_flags);
}
}
Expand Down

0 comments on commit 92d81b5

Please sign in to comment.