Null deref, asm.tabs ovf and capstone3 fixes

This commit is contained in:
Khairul Azhar Kasmiran 2021-03-15 01:12:18 +01:00 committed by pancake
parent 894bc43ea9
commit 1cec1e7419
4 changed files with 10 additions and 6 deletions

View File

@ -321,7 +321,9 @@ R_API void r_anal_set_cpu(RAnal *anal, const char *cpu) {
R_API void r_anal_set_big_endian(RAnal *anal, int bigend) {
r_return_if_fail (anal);
anal->big_endian = bigend;
anal->reg->big_endian = bigend;
if (anal->reg) {
anal->reg->big_endian = bigend;
}
}
R_API ut8 *r_anal_mask(RAnal *anal, int size, const ut8 *data, ut64 at) {

View File

@ -51,7 +51,9 @@ R_API RAnalEsilTrace *r_anal_esil_trace_new(RAnalEsil *esil) {
if (!b) {
goto error;
}
memcpy (b->bytes, a->bytes, b->size);
if (b->bytes && a->bytes && b->size > 0) {
memcpy (b->bytes, a->bytes, b->size);
}
trace->arena[i] = b;
}
return trace;

View File

@ -4159,8 +4159,8 @@ static void op_fillval (RAnal *anal, RAnalOp *op, csh handle, cs_insn *insn, int
case R_ANAL_OP_TYPE_ROR:
case R_ANAL_OP_TYPE_ROL:
case R_ANAL_OP_TYPE_CAST:
#if CS_API_MAJOR > 3
for (i = 1; i < count; i++) {
#if CS_API_MAJOR > 3
if (bits == 64) {
cs_arm64_op arm64op = INSOP64 (i);
if (arm64op.access == CS_AC_WRITE) {
@ -4173,9 +4173,9 @@ static void op_fillval (RAnal *anal, RAnalOp *op, csh handle, cs_insn *insn, int
continue;
}
}
#endif
break;
}
#endif
for (j = 0; j < 3; j++, i++) {
set_src_dst (op->src[j], anal->reg, &handle, insn, i, bits);
}

View File

@ -1451,8 +1451,8 @@ static void ds_atabs_option(RDisasmState *ds) {
if (!ds || !ds->atabs) {
return;
}
int bufasm_len = r_strbuf_length (&ds->asmop.buf_asm);
int size = bufasm_len * (ds->atabs + 1) * 4;
size_t bufasm_len = r_strbuf_length (&ds->asmop.buf_asm);
size_t size = (bufasm_len * (ds->atabs + 1)) + 8;
if (size < 1 || size < bufasm_len) {
return;
}