Repository navigation
tools/extract_offsets: fail closed on hex/malformed DWARF offsets, forward declarations, and nested members (fixes #3370) - #3371
Open
zainrizvi0611-cmd wants to merge 71 commits into
Conversation
…rward decls, and nested members (fixes limitlessprojects#3370)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3370
Summary
Hardens
tools/extract_offsets.pyso DWARF offset and struct byte-size extraction fails closed deterministically:DW_OP_plus_uconstunsigned integer parsing (_parse_dwarf_uintintools/extract_offsets.py):Parses
DW_AT_data_member_locationandDW_AT_byte_sizewith full-token anchors supporting decimal (16), hexadecimal (0x10), and(DW_OP_plus_uconst: N)forms instead ofre.search(r"...:\s*(\d+)")(which previously matched only the leading0of0x10or leading digits of malformed strings).DW_AT_byte_size(tools/extract_offsets.py):Exits non-zero (
FAILED: missing or invalid DW_AT_byte_size for ...) whenruntime.gorruntime.mis missing a validDW_AT_byte_sizeattribute instead of printingsize=None.members_ofintools/extract_offsets.py):Ignores
DW_AT_declarationforward-declaration DIEs, prefers complete struct definitions with member entries, and restricts member collection to direct children (e["depth"] == base + 1) so nested struct/union fields (depth >= base + 2) cannot overwriteruntime.gorruntime.moffsets. Also passesencoding="utf-8", errors="replace"tosubprocess.run.tools/test_extract_offsets.py):Adds
test_hex_offsets_forward_decl_and_nested_members,test_malformed_member_offset_fails_closed, andtest_missing_struct_byte_size_fails_closed.Verification
Rewards address (Base USDC / ETH):
0x0970e4ad9Ff0a9A183e9c22de4664CC4A17804e6