Skip to content

cs_disasm_iter: return early on zero-size input#2886

Merged
Rot127 merged 1 commit intocapstone-engine:nextfrom
slate5:fix/disasm-iter-zero-size
Mar 28, 2026
Merged

cs_disasm_iter: return early on zero-size input#2886
Rot127 merged 1 commit intocapstone-engine:nextfrom
slate5:fix/disasm-iter-zero-size

Conversation

@slate5
Copy link
Copy Markdown
Contributor

@slate5 slate5 commented Mar 26, 2026

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

cs_disasm_iter() does not stop when size reaches zero, allowing the backend decoder to be called with no remaining input. This results in out-of-bounds reads, observed in the RISC-V unit test introduced in #2881 under ASan.

Test plan

...

Closing issues

...

Prevent calling backend decoder with no remaining bytes,
which could lead to out-of-bounds reads.
@github-actions github-actions bot added the CS-core-files auto-sync label Mar 26, 2026
@Rot127 Rot127 merged commit dbc69c9 into capstone-engine:next Mar 28, 2026
35 checks passed
@slate5 slate5 deleted the fix/disasm-iter-zero-size branch March 28, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CS-core-files auto-sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants