Do not call r_anal_cc_arg if we don't have cc info (#12150)

This commit is contained in:
Riccardo Schirone 2018-11-14 12:14:00 +01:00 committed by radare
parent 34a6cda6f8
commit 8d9591eeaf
3 changed files with 17 additions and 13 deletions

View File

@ -674,7 +674,7 @@ R_API void extract_rarg(RAnal *anal, RAnalOp *op, RAnalFunction *fcn, int *reg_s
r_return_if_fail (anal && op && fcn);
if (!fcn->cc) {
R_LOG_INFO ("No cc information for function at %" PFMT64x " to extract register arguments\n", fcn->addr);
R_LOG_DEBUG ("No calling convention for function '%s' to extract register arguments\n", fcn->name);
return;
}

View File

@ -669,7 +669,6 @@ R_API void r_core_anal_type_match(RCore *core, RAnalFunction *fcn) {
}
}
const char *place = r_anal_cc_arg (anal, fcn->cc, 1);
// Type propgation for register based args
RList *list = r_anal_var_list (anal, fcn, R_ANAL_VAR_KIND_REG);
RAnalVar *rvar, *bp_var;
@ -707,21 +706,26 @@ R_API void r_core_anal_type_match(RCore *core, RAnalFunction *fcn) {
free (type);
r_anal_var_free (lvar);
}
r_list_free (list);
// Type propgation from caller to callee function for stack based arguments
if (place && !strncmp (place, "stack", 5)) {
RList *list2 = r_anal_var_list (anal, fcn, R_ANAL_VAR_KIND_BPV);
r_list_foreach (list2, iter2, bp_var) {
if (bp_var->isarg) {
const char *query = sdb_fmt ("fcn.0x%08"PFMT64x".arg.%d", fcn->addr, (bp_var->delta - 8));
char *type = (char *) sdb_const_get (anal->sdb_fcns, query, NULL);
if (type) {
var_retype (anal, bp_var, NULL, type, fcn->addr, false, false);
if (fcn->cc) {
const char *place = r_anal_cc_arg (anal, fcn->cc, 1);
if (place && !strncmp (place, "stack", 5)) {
RList *list2 = r_anal_var_list (anal, fcn, R_ANAL_VAR_KIND_BPV);
r_list_foreach (list2, iter2, bp_var) {
if (bp_var->isarg) {
const char *query = sdb_fmt ("fcn.0x%08" PFMT64x ".arg.%d", fcn->addr, (bp_var->delta - 8));
char *type = (char *)sdb_const_get (anal->sdb_fcns, query, NULL);
if (type) {
var_retype (anal, bp_var, NULL, type, fcn->addr, false, false);
}
}
}
r_list_free (list2);
}
r_list_free (list2);
} else {
R_LOG_DEBUG ("No calling convention set for function '%s'\n", fcn->name);
}
r_list_free (list);
out_function:
free (buf);
r_cons_break_pop();

View File

@ -2721,7 +2721,7 @@ R_API int r_core_config_init(RCore *core) {
// R2_LOGLEVEL / cfg.log.level
p = r_sys_getenv ("R2_LOGLEVEL");
SETICB ("cfg.log.level", p ? atoi(p) : R_DEFAULT_LOGLVL, cb_log_config_level, "Target log level/severity"\
" (0:SILLY, 1:VERBOSE, 2:DEBUG, 3:INFO, 4:WARN, 5:ERROR, 6:FATAL)"
" (0:SILLY, 1:DEBUG, 2:VERBOSE, 3:INFO, 4:WARN, 5:ERROR, 6:FATAL)"
);
free (p);
// R2_LOGTRAP_LEVEL / cfg.log.traplevel