From f10da2e8efaeeb47109befa8dadcbc0c815e3c0c Mon Sep 17 00:00:00 2001 From: radare Date: Mon, 6 May 2019 18:44:53 +0200 Subject: [PATCH] Fix #13975 - aho issue not showing bytes ##disasm --- libr/anal/hint.c | 4 ++-- libr/asm/op.c | 5 +---- libr/core/disasm.c | 6 ++---- libr/include/r_asm.h | 2 +- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/libr/anal/hint.c b/libr/anal/hint.c index 88e82cfb3a..83e654424c 100644 --- a/libr/anal/hint.c +++ b/libr/anal/hint.c @@ -259,9 +259,9 @@ R_API RAnalHint *r_anal_hint_from_string(RAnal *a, ut64 addr, const char *str) { case 'i': hint->immbase = sdb_atoi (nxt); break; case 'j': hint->jump = sdb_atoi (nxt); break; case 'f': hint->fail = sdb_atoi (nxt); break; - case 'p': hint->ptr = sdb_atoi (nxt); break; + case 'p': hint->ptr = sdb_atoi (nxt); break; case 'n': hint->nword = sdb_atoi (nxt); break; - case 'r': hint->ret = sdb_atoi (nxt); break; + case 'r': hint->ret = sdb_atoi (nxt); break; case 'b': hint->bits = sdb_atoi (nxt); break; case 'B': hint->new_bits = sdb_atoi (nxt); break; case 's': hint->size = sdb_atoi (nxt); break; diff --git a/libr/asm/op.c b/libr/asm/op.c index 58ae06e604..5fe32cd818 100644 --- a/libr/asm/op.c +++ b/libr/asm/op.c @@ -3,9 +3,7 @@ #include R_API RAsmOp *r_asm_op_new() { - RAsmOp *op = R_NEW (RAsmOp); - r_asm_op_init (op); - return op; + return R_NEW0 (RAsmOp); } R_API void r_asm_op_free(RAsmOp *op) { @@ -31,7 +29,6 @@ R_API char *r_asm_op_get_hex(RAsmOp *op) { int size = r_strbuf_length (&op->buf); char* str = calloc (size + 1, 2); r_return_val_if_fail (str, NULL); - r_hex_bin2str ((const ut8*) r_strbuf_get (&op->buf), size, str); return str; } diff --git a/libr/core/disasm.c b/libr/core/disasm.c index 6a009b7394..96db4fe33e 100644 --- a/libr/core/disasm.c +++ b/libr/core/disasm.c @@ -2172,7 +2172,6 @@ static int ds_disassemble(RDisasmState *ds, ut8 *buf, int len) { if (ds->hint && ds->hint->opcode) { free (ds->opstr); ds->opstr = strdup (ds->hint->opcode); - return true; } r_asm_op_fini (&ds->asmop); ret = r_asm_disassemble (core->assembler, &ds->asmop, buf, len); @@ -5373,8 +5372,7 @@ R_API int r_core_print_disasm_instructions(RCore *core, int nb_bytes, int nb_opc continue; } - // r_conf = s_printf ("0x%08"PFMT64x" ", core->offset+i); - if (ds->hint && ds->hint->size) { + if (ds->hint && ds->hint->size > 0) { ret = ds->hint->size; ds->oplen = ret; ds->analop.size = ret; @@ -5593,7 +5591,7 @@ R_API int r_core_print_disasm_json(RCore *core, ut64 addr, ut8 *buf, int nb_byte } char opstr[256]; - strcpy (opstr, r_asm_op_get_asm (&asmop)); + r_str_ncpy (opstr, r_asm_op_get_asm (&asmop), sizeof (opstr) - 1); ds->has_description = false; r_anal_op_fini (&ds->analop); diff --git a/libr/include/r_asm.h b/libr/include/r_asm.h index 12bf1a6886..8d1a12741e 100644 --- a/libr/include/r_asm.h +++ b/libr/include/r_asm.h @@ -186,8 +186,8 @@ R_API char* r_asm_code_get_hex(RAsmCode *acode); /* op.c */ R_API RAsmOp *r_asm_op_new(void); -R_API void r_asm_op_free(RAsmOp *op); R_API void r_asm_op_init(RAsmOp *op); +R_API void r_asm_op_free(RAsmOp *op); R_API void r_asm_op_fini(RAsmOp *op); R_API char *r_asm_op_get_hex(RAsmOp *op); R_API char *r_asm_op_get_asm(RAsmOp *op);