Fix last 3 mails of covs and some warnings

This commit is contained in:
pancake 2017-08-11 13:16:19 +02:00
parent 7b55621abd
commit b5c678ff6d
7 changed files with 49 additions and 46 deletions

View File

@ -48,7 +48,7 @@ hexagon_dis_inst(
if (!hexagon_dis_opcode(instrBuffer, insn, address, opcode, &errmsg)) { if (!hexagon_dis_opcode(instrBuffer, insn, address, opcode, &errmsg)) {
/* Some kind of error! */ /* Some kind of error! */
if (errmsg) { if (errmsg) {
(*info->fprintf_func) (info->stream, errmsg); (*info->fprintf_func) (info->stream, "%s", errmsg);
strcpy(instrBuffer, ""); strcpy(instrBuffer, "");
} }
} }

View File

@ -295,14 +295,17 @@ static void get_ivar_list_t(mach0_ut p, RBinFile *arch, RBinClass *klass) {
if (r != 0) { if (r != 0) {
struct MACH0_(obj_t) *bin = (struct MACH0_(obj_t) *) arch->o->bin_obj; struct MACH0_(obj_t) *bin = (struct MACH0_(obj_t) *) arch->o->bin_obj;
int is_crypted = bin->has_crypto; int is_crypted = bin->has_crypto;
if (r + left < r) return; if (r + left < r) {
if (r > arch->size || r + left > arch->size) return; goto error;
}
if (r > arch->size || r + left > arch->size) {
goto error;
}
if (is_crypted == 1) { if (is_crypted == 1) {
type = strdup ("some_encrypted_data"); type = strdup ("some_encrypted_data");
left = strlen (name) + 1; // left = strlen (name) + 1;
} else { } else {
type = malloc (left); type = calloc (1, left);
r_buf_read_at (arch->buf, r, (ut8 *)type, left); r_buf_read_at (arch->buf, r, (ut8 *)type, left);
} }
field->type = strdup (type); field->type = strdup (type);
@ -316,8 +319,7 @@ static void get_ivar_list_t(mach0_ut p, RBinFile *arch, RBinClass *klass) {
return; return;
error: error:
R_FREE (field); r_bin_field_free (field);
return;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -1420,9 +1420,10 @@ static int cmd_debug_map(RCore *core, const char *input) {
if (input[1]=='*') { if (input[1]=='*') {
mode = "-r "; mode = "-r ";
} }
ptr = strdup (r_str_trim_head ((char*)input + 2)); ptr = strdup (r_str_chop_ro (input + 2));
if (!ptr || !*ptr) { if (!ptr || !*ptr) {
r_core_cmd (core, "dmm", 0); r_core_cmd (core, "dmm", 0);
free (ptr);
break; break;
} }
i = r_str_word_set0 (ptr); i = r_str_word_set0 (ptr);
@ -2435,27 +2436,29 @@ static void backtrace_vars(RCore *core, RList *frames) {
ut64 b = f->bp ? f->bp : dbp; ut64 b = f->bp ? f->bp : dbp;
r_reg_setv (r, bp, s); r_reg_setv (r, bp, s);
r_reg_setv (r, sp, b); r_reg_setv (r, sp, b);
char flagdesc[1024], flagdesc2[1024]; //////////
RFlagItem *fi = r_flag_get_at (core->flags, f->addr, true); char flagdesc[1024], flagdesc2[1024];
flagdesc[0] = flagdesc2[0] = 0; RFlagItem *fi = r_flag_get_at (core->flags, f->addr, true);
if (f) { flagdesc[0] = flagdesc2[0] = 0;
if (fi->offset != f->addr) { if (fi) {
int delta = (int)(f->addr - fi->offset); if (fi->offset != f->addr) {
if (delta > 0) { int delta = (int)(f->addr - fi->offset);
snprintf (flagdesc, sizeof (flagdesc), if (delta > 0) {
"%s+%d", fi->name, delta); snprintf (flagdesc, sizeof (flagdesc),
} else if (delta < 0) { "%s+%d", fi->name, delta);
snprintf (flagdesc, sizeof (flagdesc), } else if (delta < 0) {
"%s%d", fi->name, delta); snprintf (flagdesc, sizeof (flagdesc),
} else { "%s%d", fi->name, delta);
snprintf (flagdesc, sizeof (flagdesc), } else {
"%s", fi->name); snprintf (flagdesc, sizeof (flagdesc),
} "%s", fi->name);
} else {
snprintf (flagdesc, sizeof (flagdesc),
"%s", fi->name);
}
} }
} else {
snprintf (flagdesc, sizeof (flagdesc),
"%s", fi->name);
}
}
//////////
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, f->addr, 0); RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, f->addr, 0);
// char *str = r_str_newf ("[frame %d]", n); // char *str = r_str_newf ("[frame %d]", n);
r_cons_printf ("%d 0x%08"PFMT64x" sp: 0x%08"PFMT64x" %-5d" r_cons_printf ("%d 0x%08"PFMT64x" sp: 0x%08"PFMT64x" %-5d"
@ -2921,6 +2924,7 @@ static void r_core_cmd_bp(RCore *core, const char *input) {
case 'w': // "dbw" case 'w': // "dbw"
input++; // skip 'w' input++; // skip 'w'
watch = true; watch = true;
// passthru
case ' ': // "db" case ' ': // "db"
for (p = input + 2; *p == ' '; p++); for (p = input + 2; *p == ' '; p++);
if (*p == '-') { if (*p == '-') {
@ -3202,17 +3206,16 @@ static void debug_trace_calls(RCore *core, const char *input) {
return; return;
} }
if (*input == ' ') { if (*input == ' ') {
ut64 first_n; input = r_str_chop_ro (input);
input = r_str_trim_head (input); ut64 first_n = r_num_math (core->num, input);
first_n = r_num_math (core->num, input);
input = strchr (input, ' '); input = strchr (input, ' ');
if (input) { if (input) {
input = r_str_trim_head (input); input = r_str_chop_ro (input);
from = first_n; from = first_n;
to = r_num_math (core->num, input); to = r_num_math (core->num, input);
input = strchr (input, ' '); input = strchr (input, ' ');
if (input) { if (input) {
input = r_str_trim_head (input); input = r_str_chop_ro (input);
final_addr = r_num_math (core->num, input); final_addr = r_num_math (core->num, input);
} }
} else { } else {

View File

@ -759,7 +759,7 @@ static int cmd_info(void *data, const char *input) {
break; break;
} }
input++; input++;
if ((*input == 'j' || *input == 'q') && !input[1]) { if ((*input == 'j' || *input == 'q') && (input[0] && !input[1])) {
break; break;
} }
} }

View File

@ -234,9 +234,11 @@ static void GH(jemalloc_print_narenas)(RCore *core, const char *input) {
} }
if (narenas == 0) { if (narenas == 0) {
eprintf ("No arenas allocated.\n"); eprintf ("No arenas allocated.\n");
free (stats);
return; return;
} }
if (narenas == GHT_MAX) { if (narenas == GHT_MAX) {
free (stats);
eprintf ("Cannot find narenas_total\n"); eprintf ("Cannot find narenas_total\n");
return; return;
} }
@ -320,6 +322,8 @@ static void GH(jemalloc_get_bins)(RCore *core, const char *input) {
} }
if (!GH(r_resolve_jemalloc)(core, "je_arena_bin_info", &bin_info)) { if (!GH(r_resolve_jemalloc)(core, "je_arena_bin_info", &bin_info)) {
eprintf ("Error resolving je_arena_bin_info\n"); eprintf ("Error resolving je_arena_bin_info\n");
free (ar);
free (b);
return; return;
} }
if (GH(r_resolve_jemalloc)(core, "je_arenas", &arenas)) { if (GH(r_resolve_jemalloc)(core, "je_arenas", &arenas)) {
@ -328,6 +332,8 @@ static void GH(jemalloc_get_bins)(RCore *core, const char *input) {
for (;;) { for (;;) {
r_core_read_at (core, arenas + i * sizeof (GHT), (ut8 *)&arena, sizeof (GHT)); r_core_read_at (core, arenas + i * sizeof (GHT), (ut8 *)&arena, sizeof (GHT));
if (!arena) { if (!arena) {
free (ar);
free (b);
break; break;
} }
PRINTF_YA (" arenas[%d]: ", i++); PRINTF_YA (" arenas[%d]: ", i++);

View File

@ -87,7 +87,6 @@ static RDebugReasonType r_debug_windbg_wait(RDebug *dbg, int pid) {
reason = R_DEBUG_REASON_INT; reason = R_DEBUG_REASON_INT;
break; break;
} }
free (pkt);
} }
free (pkt); free (pkt);
return reason; return reason;

View File

@ -25,9 +25,6 @@ static bool __plugin_open(RIO *io, const char *file, bool many) {
} }
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) { static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
void *io_ctx;
WindCtx *ctx;
if (!__plugin_open (io, file, 0)) { if (!__plugin_open (io, file, 0)) {
return NULL; return NULL;
} }
@ -37,20 +34,18 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
return NULL; return NULL;
} }
io_ctx = iob_open (file + 9); void *io_ctx = iob_open (file + 9);
if (!io_ctx) { if (!io_ctx) {
eprintf ("Could not open the pipe\n"); eprintf ("Could not open the pipe\n");
return NULL; return NULL;
} }
eprintf ("Opened pipe %s with fd %p\n", file+9, io_ctx); eprintf ("Opened pipe %s with fd %p\n", file + 9, io_ctx);
ctx = windbg_ctx_new (io_ctx);
WindCtx *ctx = windbg_ctx_new (io_ctx);
if (!ctx) { if (!ctx) {
eprintf ("Failed to initialize windbg context\n"); eprintf ("Failed to initialize windbg context\n");
return NULL; return NULL;
} }
return r_io_desc_new (&r_io_plugin_windbg, -1, file, true, mode, ctx); return r_io_desc_new (&r_io_plugin_windbg, -1, file, true, mode, ctx);
} }
@ -58,7 +53,6 @@ static int __write(RIO *io, RIODesc *fd, const ut8 *buf, int count) {
if (!fd) { if (!fd) {
return -1; return -1;
} }
if (windbg_get_target (fd->data)) { if (windbg_get_target (fd->data)) {
ut64 va; ut64 va;
if (!windbg_va_to_pa (fd->data, io->off, &va)) { if (!windbg_va_to_pa (fd->data, io->off, &va)) {
@ -66,7 +60,6 @@ static int __write(RIO *io, RIODesc *fd, const ut8 *buf, int count) {
} }
return windbg_write_at_phys (fd->data, buf, va, count); return windbg_write_at_phys (fd->data, buf, va, count);
} }
return windbg_write_at (fd->data, buf, io->off, count); return windbg_write_at (fd->data, buf, io->off, count);
} }