From b520db067fe7f43c446f989798f15c32822ec053 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 6 Nov 2023 16:29:02 +0100 Subject: [PATCH] Fix #22344 - Fix invalid json in `ax.j` command ##shell --- libr/core/cmd_anal.inc.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/libr/core/cmd_anal.inc.c b/libr/core/cmd_anal.inc.c index 5e4db2d9238a3..800225c8e6d99 100644 --- a/libr/core/cmd_anal.inc.c +++ b/libr/core/cmd_anal.inc.c @@ -9937,18 +9937,26 @@ static bool cmd_anal_refs(RCore *core, const char *input) { case ',': // "ax," r_anal_xrefs_list (core->anal, input[0], *input? r_str_trim_head_ro (input + 1): ""); break; - case '.': { // "ax." - char *tInput = strdup (input); - if (r_str_replace_ch (tInput, '.', 't', false)) { - cmd_anal_refs (core, tInput); + case '.': + if (input[1] == 'j') { // "ax.j" + r_cons_printf ("{\"to\":"); + cmd_anal_refs (core, "tj"); + r_cons_printf (",\"from\":"); + cmd_anal_refs (core, "fj"); + r_cons_printf ("}\n"); + } else { // "ax." + char *tInput = strdup (input); + if (r_str_replace_ch (tInput, '.', 't', false)) { + cmd_anal_refs (core, tInput); + } + char *fInput = strdup (input); + if (r_str_replace_ch (fInput, '.', 'f', false)) { + cmd_anal_refs (core, fInput); + } + free (tInput); + free (fInput); } - char *fInput = strdup (input); - if (r_str_replace_ch (fInput, '.', 'f', false)) { - cmd_anal_refs (core, fInput); - } - free (tInput); - free (fInput); - } break; + break; case 'm': { // "axm" char *ptr = strdup (r_str_trim_head_ro (input + 1)); int n = r_str_word_set0 (ptr);