Skip to content

Fix x86 assembler accepting invalid register names like r1 ##asm#25183

Merged
trufae merged 1 commit intoradareorg:masterfrom
0verflowme:fix/issue-25036-x86-invalid-register
Jan 7, 2026
Merged

Fix x86 assembler accepting invalid register names like r1 ##asm#25183
trufae merged 1 commit intoradareorg:masterfrom
0verflowme:fix/issue-25036-x86-invalid-register

Conversation

@0verflowme
Copy link
Copy Markdown
Member

The parseReg() function in x86_nz assembler used r_str_ncasecmp() with only the input token length, causing prefix matching. For example, 'r1' (length=2) would match the first 2 characters of 'r10', producing incorrect machine code.

Fix by adding strlen() check to ensure the register name length matches the token length exactly before comparing.

Fixes #25036

  • Mark this if you consider it ready to merge
  • I've added tests (optional)
  • I wrote some lines in the book (optional)

Description

Comment thread libr/arch/p/x86_nz/nzasm.c Outdated
The parseReg() function in x86_nz assembler used r_str_ncasecmp() with only
the input token length, causing prefix matching. For example, 'r1' (length=2)
would match the first 2 characters of 'r10', producing incorrect machine code.

Fix by adding strlen() check to ensure the register name length matches the
token length exactly before comparing.

Fixes radareorg#25036
@0verflowme 0verflowme force-pushed the fix/issue-25036-x86-invalid-register branch from d45fd9d to 5073377 Compare January 7, 2026 09:54
@trufae trufae merged commit a48410f into radareorg:master Jan 7, 2026
46 checks passed
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.

rasm2 Gives Wrong Output When Invalid Registers Are Involved

2 participants