Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'aoj' produces invalid JSON ("srcs" and "dsts") which causes an error in r2pipe #21205

Closed
find0x90 opened this issue Dec 27, 2022 · 2 comments
Closed

Comments

@find0x90
Copy link

find0x90 commented Dec 27, 2022

Environment

Mon Dec 26 23:09:34 PST 2022
radare2 5.8.1 29738 @ darwin-arm-64 git.5.8.0-23-g031da1be8f
commit: 031da1b build: 2022-12-26__22:49:25
Darwin arm64

Description

running the 'aoj' command produces JSON with invalid elements: "srcs" and "dsts".

Example:

[0x00000104]> pd1
            0x00000104      ceed                               adc 0xed
[0x00000104]> aoj ~{}
[
  {
    "opcode": "adc 0xed",
    "disasm": "adc 0xed",
    "pseudo": "0xed =  +",
    "description": "add with carry register pair",
    "srcs": [
      "name": "0xed",
      "type": "reg",
      "absolute": 1,
      "imm": 237,
      "name": "C",
      "type": "reg"
    ],
    "dsts": [
      "name": "a",
      "type": "reg"
    ],
    "mnemonic": "adc",
    "mask": "ffff",
    "esil": "0xed,a,+=,C,NUM,7,$c,C,:=,3,$c,H,:=,a,+=,7,$c,C,|,C,:=,3,$c,H,|=,a,a,=,$z,Z,:=,0,N,:=",
    "sign": false,
    "prefix": 0,
    "id": 0,
    "addr": 260,
    "bytes": "ceed",
    "size": 2,
    "type": "add",
    "esilcost": 0,
    "scale": 0,
    "refptr": 0,
    "cycles": 8,
    "failcycles": 0,
    "delay": 0,
    "stackptr": 0,
    "family": "cpu"
  }
]

This portion is invalid:

    "srcs": [
      "name": "0xed",
      "type": "reg",
      "absolute": 1,
      "imm": 237,
      "name": "C",
      "type": "reg"
    ],
    "dsts": [
      "name": "a",
      "type": "reg"
    ],

Perhaps the contents of these lists are supposed to be objects themselves? Like this:

    "srcs": [
      {
        "name": "0xed",
        "type": "reg",
        "absolute": 1,
        "imm": 237
      },
      {
        "name": "C",
        "type": "reg"
      }
    ],
    "dsts": [
      {
        "name": "a",
        "type": "reg"
      }
    ],

Looks like this was introduced here dab6e8f

Test

I can't distribute the executable in which I originally encountered this but I can try to find another case where this occurs if necessary.

@trufae trufae closed this as completed in d2c8770 Dec 28, 2022
@trufae
Copy link
Collaborator

trufae commented Dec 28, 2022

thanks for spotting it! im going to add tests for this!

@find0x90
Copy link
Author

Just pulled and it's fixed on my end, thank you!

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

No branches or pull requests

2 participants