Add esil.maxsteps to avoid infinite emulation loops ##esil

This commit is contained in:
Sergi Àlvarez i Capilla 2022-03-23 11:55:50 +01:00 committed by pancake
parent 6c868bb010
commit 4abf7bf9ba
2 changed files with 6 additions and 2 deletions

View File

@ -3433,6 +3433,7 @@ R_API int r_core_config_init(RCore *core) {
#endif
SETBPREF ("dbg.glibc.demangle", "false", "Demangle linked-lists pointers introduced in glibc 2.32");
SETBPREF ("esil.prestep", "true", "Step before esil evaluation in `de` commands");
SETI ("esil.maxsteps", 0, "If !=0 defines the maximum amount of steps to perform on aesu/aec/..");
SETPREF ("esil.fillstack", "", "Initialize ESIL stack with (random, debrujn, sequence, zeros, ...)");
SETICB ("esil.verbose", 0, &cb_esilverbose, "Show ESIL verbose level (0, 1, 2)");
SETICB ("esil.gotolimit", core->anal->esil_goto_limit, &cb_gotolimit, "Maximum number of gotos per ESIL expression");

View File

@ -847,10 +847,13 @@ static int step_until_optype(RCore *core, const char *_optypes) {
ut8 buf[32];
ut64 pc;
int res = true;
st64 maxsteps = r_config_get_i (core->config, "esil.maxsteps");
ut64 countsteps = 0;
RList *optypes_list = NULL;
RListIter *iter;
char *optype, *optypes = strdup (r_str_trim_head_ro ((char *) _optypes));
char *optype = NULL;
char *optypes = strdup (r_str_trim_head_ro ((char *) _optypes));
if (!core || !core->dbg) {
eprintf ("Wrong state\n");
@ -867,7 +870,7 @@ static int step_until_optype(RCore *core, const char *_optypes) {
optypes_list = r_str_split_list (optypes, " ", 0);
r_cons_break_push (NULL, NULL);
for (;;) {
for (; !maxsteps || countsteps < maxsteps; countsteps++) {
if (r_cons_is_breaked ()) {
core->break_loop = true;
break;