Skip to content

fix(core): prevent overflow in range and capture checks - #4223

Draft
bobzhang wants to merge 1 commit into
mainfrom
codex/core-audit-bounds
Draft

bobzhang wants to merge 1 commit into
mainfrom
codex/core-audit-bounds

Conversation

@bobzhang

Copy link
Copy Markdown
Contributor

Large offsets, lengths, and capture indices can overflow signed Int arithmetic and bypass range checks. For example, [1, 2].chunks(2147483647) returns an empty array, and an overflowing regex group index can resolve to group 0.

Use subtraction-based bounds checks for byte copies and Deque ranges, overflow-safe chunk calculations, and validation before multiplying capture indices. Add regression cases for overflowing inputs and valid empty ranges.

Validation:

  • moon check --deny-warn
  • moon test builtin deque string --target all
  • moon info; generated interfaces unchanged

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 6621

Coverage remained the same at 89.314%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 5 of 5 lines across 4 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 18408
Covered Lines: 16441
Line Coverage: 89.31%
Coverage Strength: 280806.47 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants