From 25690a9045b6306413e783dac792f4fb420904d4 Mon Sep 17 00:00:00 2001 From: Giovanni <561184+wargio@users.noreply.github.com> Date: Wed, 5 Feb 2025 10:19:49 +0800 Subject: [PATCH] Fix null deref and output of aezsue (#4877) --- librz/arch/il/analysis_il.c | 6 +++--- librz/core/cil.c | 7 ++++--- librz/include/rz_il/rz_il_opbuilder_begin.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/librz/arch/il/analysis_il.c b/librz/arch/il/analysis_il.c index e81da3891ef..9847d748104 100644 --- a/librz/arch/il/analysis_il.c +++ b/librz/arch/il/analysis_il.c @@ -96,7 +96,7 @@ static void setup_vm_init_state(RzAnalysisILVM *vm, RZ_NULLABLE RzAnalysisILInit * \return RzAnalysisRzil* a pointer to RzAnalysisILVM instance */ RZ_API RZ_OWN RzAnalysisILVM *rz_analysis_il_vm_new(RzAnalysis *a, RZ_NULLABLE RzReg *init_state_reg) { - rz_return_val_if_fail(a, NULL); + rz_return_val_if_fail(a && a->cur && a->cur->il_config, NULL); RzAnalysisILConfig *config = a->cur->il_config(a); if (!config) { return false; @@ -281,9 +281,9 @@ static RzAnalysisILStepResult analysis_il_vm_step_while( rz_strbuf_append(&sb, "\n"); il_events(vm->vm, &sb); - rz_cons_printf("0x%llx [", addr); + rz_cons_printf("0x%08" PFMT64x " [", addr); for (int i = 0; i < op.size; ++i) { - rz_cons_printf("%x", code[i]); + rz_cons_printf("%02x", code[i]); } rz_cons_printf("] %s\n%s\n", op.mnemonic, rz_strbuf_get(&sb)); rz_cons_flush(); diff --git a/librz/core/cil.c b/librz/core/cil.c index 811a52bfdf7..a21c3a5f9ea 100644 --- a/librz/core/cil.c +++ b/librz/core/cil.c @@ -683,9 +683,10 @@ static bool step_handle_result(RzCore *core, RzAnalysisILStepResult r) { RZ_LOG_ERROR("RzIL: invalid instruction or lifting not implemented at address 0x%08" PFMT64x "\n", rz_reg_get_value_by_role(core->analysis->reg, RZ_REG_NAME_PC)); break; - default: - RZ_LOG_ERROR("RzIL: stepping failed.\n"); - break; + default: { + ut64 addr = rz_bv_to_ut64(core->analysis->il_vm->vm->pc); + RZ_LOG_ERROR("RzIL: stepping failed with PC at 0x%" PFMT64x ".\n", addr); + } break; } return false; } diff --git a/librz/include/rz_il/rz_il_opbuilder_begin.h b/librz/include/rz_il/rz_il_opbuilder_begin.h index 97cf8d33c68..6cff155c488 100644 --- a/librz/include/rz_il/rz_il_opbuilder_begin.h +++ b/librz/include/rz_il/rz_il_opbuilder_begin.h @@ -138,6 +138,7 @@ #define MSB(x) rz_il_op_new_msb(x) #define LSB(x) rz_il_op_new_lsb(x) #define EQ(x, y) rz_il_op_new_eq(x, y) +#define NE(x, y) rz_il_op_new_ne(x, y) #define ULT(x, y) rz_il_op_new_ult(x, y) #define ULE(x, y) rz_il_op_new_ule(x, y) #define UGT(x, y) rz_il_op_new_ugt(x, y) @@ -191,6 +192,5 @@ #define BSWAP16(t) rz_il_bswap16(t) #define BSWAP32(t) rz_il_bswap32(t) #define BSWAP64(t) rz_il_bswap64(t) -#define NE(x, y) rz_il_op_new_ne(x, y) #endif