Skip to content

Commit

Permalink
Fix /wi by removing wrong fallthrough (#3636)
Browse files Browse the repository at this point in the history
/wi was falling through the switch case and it was not accepting the
input correctly. Fix this by breaking at the end of the '/w' case so
that the search can begin.
  • Loading branch information
ret2libc authored Jul 4, 2023
1 parent 1f30b7f commit 194eaba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
12 changes: 1 addition & 11 deletions librz/core/cmd/cmd_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -3538,7 +3538,7 @@ RZ_IPI int rz_cmd_search(void *data, const char *input) {
RZ_LOG_ERROR("core: Invalid keyword\n");
break;
}
// fallthrough
break;
case 'i': // "/i"
if (input[param_offset - 1] != ' ') {
RZ_LOG_ERROR("core: Missing ' ' after /i\n");
Expand All @@ -3555,16 +3555,6 @@ RZ_IPI int rz_cmd_search(void *data, const char *input) {
case ' ': // "/ " search string
inp = strdup(input + 1 + ignorecase + (param.outmode == RZ_MODE_JSON ? 1 : 0));
len = rz_str_unescape(inp);
#if 0
if (!json) {
eprintf ("Searching %d byte(s) from 0x%08"PFMT64x " to 0x%08"PFMT64x ": ",
len, search_itv.addr, rz_itv_end (search_itv));
for (i = 0; i < len; i++) {
eprintf ("%02x ", (ut8) inp[i]);
}
eprintf ("\n");
}
#endif
rz_search_reset(core->search, RZ_SEARCH_KEYWORD);
rz_search_set_distance(core->search, (int)rz_config_get_i(core->config, "search.distance"));
{
Expand Down
19 changes: 19 additions & 0 deletions test/db/cmd/cmd_search
Original file line number Diff line number Diff line change
Expand Up @@ -1161,3 +1161,22 @@ rzil.step.events.read: enables/disables printing aezse read event
rzil.step.events.write: enables/disables printing aezse write event
EOF
RUN


NAME=search wide string
FILE==
CMDS=<<EOF
ww Hello World this is Rizin
/w World
/w world
/wi world
/wj World
/wji world
EOF
EXPECT=<<EOF
0x0000000c hit0_0 57006f0072006c006400
0x0000000c hit2_0 57006f0072006c006400
[{"offset":12,"type":"hexpair","data":"57006f0072006c006400"}]
[{"offset":12,"type":"hexpair","data":"57006f0072006c006400"}]
EOF
RUN

0 comments on commit 194eaba

Please sign in to comment.