Skip to content

UPSTREAM PREP: reject conditional jumps exceeding 255 instructions - #4

Draft
blb4github wants to merge 2 commits into
mainfrom
fix/upstream-rules-jump-overflow
Draft

blb4github wants to merge 2 commits into
mainfrom
fix/upstream-rules-jump-overflow

Conversation

@blb4github

Copy link
Copy Markdown
Owner

Intended upstream: CurlyMoo/rules

Staged independently on the fork's main branch because upstream PR creation is denied (HTTP 403).

Summary

The compact Rules VM stores forward jump distances in an unsigned 8-bit operand. A jump longer than 255 instructions previously truncated silently, possibly jumping into an incorrect conditional branch.

Fix

  • Check bounds before encoding forward conditional offsets in BOTH compiler backpatch locations (if/elseif/else and end).
  • Log rule number, computed distance, and the 255-instruction limit, then fail compilation.
  • Preserve 4-byte bytecode; no automatic long-jump rewrite.

Evidence

Review checklist

  • Run upstream CI
  • Confirm compiler failure propagates correctly in downstream clients

Independent change: does not depend on increasing the variable limit. Do not merge here.

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.

1 participant