mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-12 15:38:09 +00:00
Fix UAF in cb_asmarch
This commit is contained in:
parent
f36cfc2614
commit
088c13ddad
@ -303,7 +303,9 @@ static int has_bits(RAsmPlugin *h, int bits) {
|
||||
}
|
||||
|
||||
R_API void r_asm_set_cpu(RAsm *a, const char *cpu) {
|
||||
if (a) {
|
||||
free (a->cpu);
|
||||
}
|
||||
a->cpu = cpu? strdup (cpu): NULL;
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,9 @@ static int cb_asmarch(void *user, void *data) {
|
||||
eprintf ("asm.arch: cannot find (%s)\n", node->value);
|
||||
return false;
|
||||
}
|
||||
const char *asm_cpu = r_config_get (core->config, "asm.cpu");
|
||||
//we should strdup here otherwise will crash if any r_config_set
|
||||
//free the old value
|
||||
char *asm_cpu = strdup (r_config_get (core->config, "asm.cpu"));
|
||||
if (core->assembler->cur) {
|
||||
const char *newAsmCPU = core->assembler->cur->cpus;
|
||||
if (newAsmCPU) {
|
||||
@ -351,6 +353,7 @@ static int cb_asmarch(void *user, void *data) {
|
||||
core->print->big_endian = bigbin;
|
||||
}
|
||||
r_asm_set_cpu (core->assembler, asm_cpu);
|
||||
free (asm_cpu);
|
||||
/* reload types and cc info */
|
||||
r_core_anal_type_init (core);
|
||||
r_core_anal_cc_init (core);
|
||||
|
Loading…
Reference in New Issue
Block a user