mirror of
https://github.com/morluto/rea.git
synced 2026-12-02 03:25:20 +00:00
* fix(ghidra): refuse over-deep caller types before Ghidra parses them The 256-level type-depth bound ran only after Ghidra's C parser returned, but the parser recurses over a declarator's pointer and array chain. On a JVM whose stack it exhausts (Ghidra 12.2 under WSL2), define_native_data_types surfaced the generic unclassified provider failure instead of the resource_constraint refusal naming the exceeded limit. Measure the same chain from the admitted tokens before parsing: each pointer, array, typedef, bit-field, function and composite level adds one, base names resolve through types defined earlier in the text and then the database, and a reference back into a composite still being measured adds no depth. The post-parse walk remains the authority for chains through database types a definition fills in place. * fix(ghidra): measure grouped declarators and separate tag depths The pre-parse depth pass read the caller text a second time instead of measuring the tokens admission already produced. It also counted a typedef level for an anonymous composite, which Ghidra stores as the composite itself, so an allowed 256-level type was refused; kept tag and typedef depths in one map, so a typedef sharing a tag name reset the chain later composites build on; and left grouped declarators unmeasured, so an over-deep grouped signature still reached the parser. Measure the admitted tokens, track tag and ordinary names apart, count an anonymous composite typedef as the composite, and measure grouped and trailing function declarators. The real-Ghidra verifier now covers the 256/257 anonymous boundary, a grouped signature flood, and the shared tag and typedef name chain. * fix(ghidra): measure stars behind calling conventions in grouped declarators A convention inside a function-pointer parenthesis, before or after the stars, made the pre-parse depth measure give up and send the chain to Ghidra unmeasured. Conventions are now skipped around the star count in declarators and signatures, so over-deep chains refuse before parsing. The shared tag and typedef verifier case now asserts the conflicting definitions refusal it actually produces, and a convention-prefixed flood case covers the measured chain. * fix(ghidra): fail closed on partial over-deep declarators The pre-parse depth measure discarded an already-counted over-deep parameter when a missing closing parenthesis made the declarator unmeasured, sending the chain to Ghidra's parser. Partial declarator, array, parameter, composite, and signature measurements now retain their deepest count, so an over-deep chain refuses before parsing. A redundant forward declaration also overwrote a completed tag depth with 1, hiding later definitions chained through that tag. Tag depths now never fall. The real-provider verifier covers both cases. * fix(ghidra): separate in-progress tags and count grouped arrays The pre-parse depth measure treated a same-named typedef as recursive while its tag body was being measured, so the typedef depth did not chain through the member. In-progress tags are now tracked apart from ordinary names. Grouped signature names also left their array suffixes unmeasured, so an over-deep pointer and array chain could reach Ghidra's parser. Signature measurement now counts those suffixes before expecting the parameter list. The real-provider verifier covers both cases. * fix(ghidra): measure arrays after each grouped declarator close * fix(ghidra): measure trailing and nested signature declarators * fix(ghidra): descend nested grouped declarators in depth preflight A pointer group that itself groups the declarator, as in (*(*f)), stopped measurement at the outer star and then threw on the inner parenthesis, leaving the inner pointer chain uncounted. Accumulate stars across nested groups so the whole chain is measured before Ghidra parses it, and cover the nested case in the real-provider verifier. * fix(ghidra): parse caller C on a fixed stack before the depth walk Ghidra's C parser recurses once per pointer and can exhaust a 1 MiB thread stack before the iterative depth walk runs, so the 256-level ceiling surfaced as an unclassified bridge exception. Parsing on a 16 MiB thread lets that walk remain the authority and report type_depth_limit. A parser overflow on that thread is the same refusal. The hand-rolled declarator preflight is removed. * test(ghidra): refuse an unnamed grouped abstract declarator The depth ceiling is measured from the parsed type, so an abstract parameter (__stdcall *[])(void) is the same refusal as the named form. Co-authored-by: morluto <morluto@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com>