Skip to content

Commit

Permalink
Enforce valid value for asm.offset.relto ##config
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae authored Sep 25, 2024
1 parent 23223ee commit 2fba905
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions libr/core/cconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -1612,10 +1612,18 @@ static bool cb_color_getter(void *user, RConfigNode *node) {
}

static bool cb_reloff(void *user, void *data) {
// RCore *core = (RCore *) user;
const char options[] = "func\nflag\nmaps\ndmap\nfmap\nsect\nsymb\nlibs\nfile\n";
RConfigNode *node = (RConfigNode *) data;
if (strchr (node->value, '?')) {
r_cons_printf ("func\nflag\nmaps\ndmap\nfmap\nsect\nsymb\nlibs\nfile\n");
if (*node->value) {
char *pos = strstr (options, node->value);
if (pos && pos[strlen (node->value)] == '\n') {
return true;
}
if (strchr (node->value, '?')) {
r_cons_printf (options);
} else {
R_LOG_ERROR ("Invalid value, try `-e asm.offset.relto=?`");
}
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion test/db/cmd/cmd_pd_bugs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ NAME=pd+reloff+colors
FILE=bins/elf/analysis/ls-alxchk
CMDS=<<EOF
af
e asm.offset.relto=fun
e asm.offset.relto=func
pd 10
e scr.color=1
pd 10
Expand Down

0 comments on commit 2fba905

Please sign in to comment.