Skip to content

JSON output issue for some search commands #24812

@sagittarius-a

Description

@sagittarius-a

Environment

Mon Nov 10 00:18:51 CET 2025
radare2 6.0.4 0 @ darwin-arm-64
birth: git.6.0.4 2025-09-27__18:08:23
commit: 6.0.4
options: gpl release -O1 cs:5 cl:2 make
Darwin arm64

Description

Search results are not wrapper in a JSON array (for some commands only). It is especially problematic using pretty-printed JSON, since the generated JSON is not valid (see below).

Test

❯ r2 ./test/db/bins/elf/ioli/crackme0x00
[0x08048360]> /ej /IO/~{}
{
  "addr": 134513271,
  "type": "string",
  "data": "fstrcmpscanf_IO_stdin_used__li"
}{
  "addr": 134514024,
  "type": "string",
  "data": "Y[IOLI Crackme Level"
}
[0x08048360]> /ej /IO/
{"addr":134513271,"type":"string","data":"fstrcmpscanf_IO_stdin_used__li"},{"addr":134514024,"type":"string","data":"Y[IOLI Crackme Level"}
[0x08048360]>

Works on /k command as well.

I think the common point between the two is the dosearch_read = true, which then uses a special code path. Using the _cb_hit_sz() as callback it seems to add matches as JSON. However, the matches are not wrapped in an array.

I'm not exactly sure where the array creation is supposed to be performed,
this is why I did create the issue instead of submitting a merge request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions