Fix / dij json output, but spotted by @sha0coder ##search

This commit is contained in:
pancake 2024-11-22 16:27:42 +01:00
parent ff432b6da2
commit b60135be09
2 changed files with 24 additions and 21 deletions

View File

@ -4058,19 +4058,21 @@ static int chatoi(const char *arg) {
static bool is_json_command(const char *input, int *param_offset) {
const char *lastch = strchr (input, ' ');
const char *nextch = NULL;
if (lastch && lastch > input) {
lastch--;
nextch = r_str_trim_head_ro (lastch);
} else {
lastch = input + strlen (input) - 1;
}
if (param_offset) {
if (*lastch && lastch[1]) {
int delta = 2 + (nextch - input);
*param_offset = delta;
if (lastch) {
if (lastch > input) {
lastch--;
const char *nextch = r_str_trim_head_ro (lastch);
if (param_offset) {
if (*lastch && lastch[1]) {
int delta = 2 + (nextch - input);
*param_offset = delta;
}
}
return (*lastch == 'j');
}
return false;
}
lastch = input + strlen (input) - 1;
return (*lastch == 'j');
}
@ -5029,16 +5031,6 @@ reread:
}
// fallthrough
case ' ': // "/ " search string
#if 0
if (!json) {
eprintf ("Searching %d byte(s) from 0x%08"PFMT64x " to 0x%08"PFMT64x ": ",
len, search_itv.addr, r_itv_end (search_itv));
for (i = 0; i < len; i++) {
eprintf ("%02x ", (ut8) inp[i]);
}
eprintf ("\n");
}
#endif
{
const int distance = r_config_get_i (core->config, "search.distance");
inp = strdup (input + 1 + ignorecase + (param.outmode == R_MODE_JSON ? 1 : 0));

View File

@ -7,6 +7,17 @@ EOF
EXPECT=
RUN
NAME=search dij
FILE=malloc://1024
CMDS=<<EOF
w foo-di-dij-bar
/ dij
EOF
EXPECT=<<EOF
0x00000007 hit0_0 "foo-di-dij-bar"
EOF
RUN
NAME=search esil
FILE=bins/elf/ioli/crackme0x00
CMDS=<<EOF