Skip to content

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

@find0x90

Description

@find0x90

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions