mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-13 18:32:56 +00:00
Fix asserts when trying to use a unexistant or wrong analysis plugin ##anal (#16542)
This commit is contained in:
parent
790100b7bc
commit
e650b7dcc7
@ -4003,12 +4003,14 @@ static void __anal_reg_list(RCore *core, int type, int bits, char mode) {
|
||||
if (mode == '=') {
|
||||
int pcbits = 0;
|
||||
const char *pcname = r_reg_get_name (core->anal->reg, R_REG_NAME_PC);
|
||||
RRegItem *reg = r_reg_get (core->anal->reg, pcname, 0);
|
||||
if (bits != reg->size) {
|
||||
pcbits = reg->size;
|
||||
}
|
||||
if (pcbits) {
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, pcbits, mode, use_color); // XXX detect which one is current usage
|
||||
if (pcname) {
|
||||
RRegItem *reg = r_reg_get (core->anal->reg, pcname, 0);
|
||||
if (reg && bits != reg->size) {
|
||||
pcbits = reg->size;
|
||||
}
|
||||
if (pcbits) {
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, pcbits, mode, use_color); // XXX detect which one is current usage
|
||||
}
|
||||
}
|
||||
}
|
||||
r_debug_reg_list (core->dbg, type, bits, mode2, use_color);
|
||||
@ -4355,7 +4357,9 @@ void cmd_anal_reg(RCore *core, const char *str) {
|
||||
int role = r_reg_get_name_idx (regname);
|
||||
if (role != -1) {
|
||||
const char *alias = r_reg_get_name (core->dbg->reg, role);
|
||||
r = r_reg_get (core->dbg->reg, alias, -1);
|
||||
if (alias) {
|
||||
r = r_reg_get (core->dbg->reg, alias, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (r) {
|
||||
@ -10024,7 +10028,7 @@ static int cmd_anal(void *data, const char *input) {
|
||||
switch (input[1]) {
|
||||
case 'f': // "adf"
|
||||
if (input[2] == 'g') {
|
||||
anal_fcn_data_gaps (core, input + 1);
|
||||
anal_fcn_data_gaps (core, r_str_trim_head_ro (input + 1));
|
||||
} else {
|
||||
anal_fcn_data (core, input + 1);
|
||||
}
|
||||
|
@ -2385,7 +2385,7 @@ static void cmd_debug_reg(RCore *core, const char *str) {
|
||||
case 'C': // "drC"
|
||||
{
|
||||
const bool json_out = str[1] == 'j';
|
||||
name = json_out ? str + 3 : str + 2;
|
||||
name = r_str_trim_head_ro (json_out ? str + 3 : str + 2);
|
||||
if (name) {
|
||||
r = r_reg_get (core->dbg->reg, name , -1);
|
||||
if (r) {
|
||||
|
@ -101,7 +101,6 @@ static int getreloc_tree(const void *user, const RBNode *n, void *user2) {
|
||||
if ((r->vaddr >= gr->vaddr) && (r->vaddr < (gr->vaddr + gr->size))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (gr->vaddr > r->vaddr) {
|
||||
return 1;
|
||||
}
|
||||
@ -341,48 +340,6 @@ R_API RCore *r_core_cast(void *p) {
|
||||
return (RCore*)p;
|
||||
}
|
||||
|
||||
static void core_post_write_callback(void *user, ut64 maddr, ut8 *bytes, int cnt) {
|
||||
RCore *core = (RCore *)user;
|
||||
RBinSection *sec;
|
||||
ut64 vaddr;
|
||||
|
||||
if (!r_config_get_i (core->config, "asm.cmt.patch")) {
|
||||
return;
|
||||
}
|
||||
|
||||
char *hex_pairs = r_hex_bin2strdup (bytes, cnt);
|
||||
if (!hex_pairs) {
|
||||
eprintf ("core_post_write_callback: Cannot obtain hex pairs\n");
|
||||
return;
|
||||
}
|
||||
|
||||
char *comment = r_str_newf ("patch: %d byte(s) (%s)", cnt, hex_pairs);
|
||||
free (hex_pairs);
|
||||
if (!comment) {
|
||||
eprintf ("core_post_write_callback: Cannot create comment\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((sec = r_bin_get_section_at (r_bin_cur_object (core->bin), maddr, false))) {
|
||||
vaddr = maddr + sec->vaddr - sec->paddr;
|
||||
} else {
|
||||
vaddr = maddr;
|
||||
}
|
||||
|
||||
r_meta_add (core->anal, R_META_TYPE_COMMENT, vaddr, vaddr, comment);
|
||||
free (comment);
|
||||
}
|
||||
|
||||
static int core_cmd_callback (void *user, const char *cmd) {
|
||||
RCore *core = (RCore *)user;
|
||||
return r_core_cmd0 (core, cmd);
|
||||
}
|
||||
|
||||
static char *core_cmdstr_callback (void *user, const char *cmd) {
|
||||
RCore *core = (RCore *)user;
|
||||
return r_core_cmd_str (core, cmd);
|
||||
}
|
||||
|
||||
static ut64 getref (RCore *core, int n, char t, int type) {
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset, 0);
|
||||
RListIter *iter;
|
||||
|
Loading…
x
Reference in New Issue
Block a user