mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 15:10:53 +00:00
Minor cleanups/fixes (#12478)
This commit is contained in:
parent
519c969e5c
commit
5b644dcb74
@ -1023,7 +1023,6 @@ int main(int argc, char **argv) {
|
||||
r_bin_set_baddr (bin, baddr);
|
||||
}
|
||||
if (rawstr == 2) {
|
||||
rawstr = false;
|
||||
RBinFile *bf = r_core_bin_cur (&core);
|
||||
if (bf) {
|
||||
bf->strmode = rad;
|
||||
|
@ -285,6 +285,7 @@ int main(int argc, char **argv) {
|
||||
r_egg_free (egg);
|
||||
return usage (1);
|
||||
case 'v':
|
||||
free (sequence);
|
||||
r_egg_free (egg);
|
||||
return blob_version("ragg2");
|
||||
case 'z':
|
||||
|
@ -117,7 +117,6 @@ static int wasm_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len
|
||||
wasm_stack[wasm_stack_ptr].end = addr2;
|
||||
wasm_stack[wasm_stack_ptr].size = wop.len;
|
||||
wasm_stack_ptr++;
|
||||
addr2 = UT64_MAX;
|
||||
}
|
||||
//op->fail = addr + op->size;
|
||||
break;
|
||||
@ -129,7 +128,6 @@ static int wasm_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len
|
||||
wasm_stack[wasm_stack_ptr].end = addr2;
|
||||
wasm_stack[wasm_stack_ptr].size = wop.len;
|
||||
wasm_stack_ptr++;
|
||||
addr2 = UT64_MAX;
|
||||
}
|
||||
break;
|
||||
case WASM_OP_IF:
|
||||
|
@ -4805,7 +4805,7 @@ static int thumb_assemble(ArmOpcode *ao, ut64 off, const char *str) {
|
||||
if ((num > 4095) || (num < -255)) {
|
||||
return -1;
|
||||
}
|
||||
if ((num >= 0) && (num < 4096)) {
|
||||
if (num >= 0) {
|
||||
if (strsel == 0) {
|
||||
ao->o = 0xc0f80000;
|
||||
} else
|
||||
|
@ -625,7 +625,7 @@ static Sdb *store_versioninfo_gnu_versym(ELFOBJ *bin, Elf_(Shdr) *shdr, int sz)
|
||||
return NULL;
|
||||
}
|
||||
Elf_(Shdr) *link_shdr = &bin->shdr[shdr->sh_link];
|
||||
ut8 *edata = (ut8*) calloc (R_MAX (1, num_entries), sizeof (ut16));
|
||||
ut8 *edata = (ut8*) calloc (R_MAX (1, num_entries), 2 * sizeof (ut8));
|
||||
if (!edata) {
|
||||
sdb_free (sdb);
|
||||
return NULL;
|
||||
|
@ -856,6 +856,10 @@ static int dyldcache_io_read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
|
||||
ut8 *internal_buf = rebase_info->one_page_buf;
|
||||
if (rounded_count > rebase_info->page_size) {
|
||||
internal_buf = malloc (rounded_count);
|
||||
if (!internal_buf) {
|
||||
eprintf ("Cannot allocate memory for 'internal_buf'\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
ut64 original_off = io->off;
|
||||
|
@ -3292,13 +3292,13 @@ R_API int r_core_anal_search_xrefs(RCore *core, ut64 from, ut64 to, int rad) {
|
||||
memset (block, -1, bsz);
|
||||
if (!memcmp (buf, block, bsz)) {
|
||||
// eprintf ("Error: skipping uninitialized block \n");
|
||||
at += bsz;
|
||||
at += ret;
|
||||
continue;
|
||||
}
|
||||
memset (block, 0, bsz);
|
||||
if (!memcmp (buf, block, bsz)) {
|
||||
// eprintf ("Error: skipping uninitialized block \n");
|
||||
at += bsz;
|
||||
at += ret;
|
||||
continue;
|
||||
}
|
||||
while (i < bsz && !r_cons_is_breaked ()) {
|
||||
|
@ -3355,9 +3355,6 @@ R_API void r_core_bin_export_info_rad(RCore *core) {
|
||||
return;
|
||||
}
|
||||
db = sdb_ns (bf->sdb, "info", 0);;
|
||||
if (!db) {
|
||||
return;
|
||||
}
|
||||
if (db) {
|
||||
SdbListIter *iter;
|
||||
SdbKv *kv;
|
||||
|
@ -4260,13 +4260,11 @@ static int cmd_print(void *data, const char *input) {
|
||||
int buf_len;
|
||||
r_str_bits (buf, block, size, NULL);
|
||||
buf_len = strlen (buf);
|
||||
if (from < 0 || to < 0) {
|
||||
// do nothing
|
||||
} else {
|
||||
if (from >= 0 && to >= 0) {
|
||||
if (from >= buf_len) {
|
||||
from = buf_len;
|
||||
}
|
||||
if (to >= 0 && to < buf_len) {
|
||||
if (to < buf_len) {
|
||||
buf[to] = 0;
|
||||
//buf[buf_len - 1] = 0;
|
||||
}
|
||||
|
@ -4473,7 +4473,7 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
|
||||
case R_CONS_KEY_F7:
|
||||
cmd = r_config_get (core->config, "key.f7");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
} else {
|
||||
graph_single_step_in (core, g);
|
||||
}
|
||||
@ -4481,7 +4481,7 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
|
||||
case R_CONS_KEY_F8:
|
||||
cmd = r_config_get (core->config, "key.f8");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
} else {
|
||||
graph_single_step_over (core, g);
|
||||
}
|
||||
@ -4489,7 +4489,7 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
|
||||
case R_CONS_KEY_F9:
|
||||
cmd = r_config_get (core->config, "key.f9");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
} else {
|
||||
graph_continue (core);
|
||||
}
|
||||
|
@ -3355,13 +3355,13 @@ repeat:
|
||||
case R_CONS_KEY_F1:
|
||||
cmd = r_config_get (core->config, "key.f1");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
}
|
||||
break;
|
||||
case R_CONS_KEY_F2:
|
||||
cmd = r_config_get (core->config, "key.f2");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
} else {
|
||||
panelBreakpoint (core);
|
||||
}
|
||||
@ -3369,31 +3369,31 @@ repeat:
|
||||
case R_CONS_KEY_F3:
|
||||
cmd = r_config_get (core->config, "key.f3");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
}
|
||||
break;
|
||||
case R_CONS_KEY_F4:
|
||||
cmd = r_config_get (core->config, "key.f4");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
}
|
||||
break;
|
||||
case R_CONS_KEY_F5:
|
||||
cmd = r_config_get (core->config, "key.f5");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
}
|
||||
break;
|
||||
case R_CONS_KEY_F6:
|
||||
cmd = r_config_get (core->config, "key.f6");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
}
|
||||
break;
|
||||
case R_CONS_KEY_F7:
|
||||
cmd = r_config_get (core->config, "key.f7");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
} else {
|
||||
panelSingleStepIn (core);
|
||||
setRefreshAll (panels, false);
|
||||
@ -3402,7 +3402,7 @@ repeat:
|
||||
case R_CONS_KEY_F8:
|
||||
cmd = r_config_get (core->config, "key.f8");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
} else {
|
||||
panelSingleStepOver (core);
|
||||
setRefreshAll (panels, false);
|
||||
@ -3411,7 +3411,7 @@ repeat:
|
||||
case R_CONS_KEY_F9:
|
||||
cmd = r_config_get (core->config, "key.f9");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
} else {
|
||||
panelContinue (core);
|
||||
}
|
||||
@ -3419,19 +3419,19 @@ repeat:
|
||||
case R_CONS_KEY_F10:
|
||||
cmd = r_config_get (core->config, "key.f10");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
}
|
||||
break;
|
||||
case R_CONS_KEY_F11:
|
||||
cmd = r_config_get (core->config, "key.f11");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
}
|
||||
break;
|
||||
case R_CONS_KEY_F12:
|
||||
cmd = r_config_get (core->config, "key.f12");
|
||||
if (cmd && *cmd) {
|
||||
key = r_core_cmd0 (core, cmd);
|
||||
(void)r_core_cmd0 (core, cmd);
|
||||
}
|
||||
break;
|
||||
case '!':
|
||||
|
@ -25,7 +25,7 @@ static int __esil_step(RDebug *dbg) {
|
||||
ut64 pc = 0LL; // getreg("pc")
|
||||
RAnalOp op = {0};
|
||||
|
||||
pc = r_debug_reg_sync(dbg, R_REG_TYPE_GPR, false);
|
||||
r_debug_reg_sync(dbg, R_REG_TYPE_GPR, false);
|
||||
pc = r_debug_reg_get (dbg, "PC");
|
||||
eprintf ("PC = 0x%" PFMT64x "\n", pc);
|
||||
/// XXX. hack to trick vaddr issue
|
||||
|
@ -146,7 +146,6 @@ R_API RSearchKeyword* r_search_keyword_new_hex(const char *kwstr, const char *bm
|
||||
}
|
||||
bmlen = r_hex_str2bin (bmstr, bmbuf);
|
||||
if (bmlen < 1) {
|
||||
bmlen = -bmlen;
|
||||
free (bmbuf);
|
||||
free (kwbuf);
|
||||
return NULL;
|
||||
|
@ -78,7 +78,7 @@ R_API int r_search_strings_update(RSearch *s, ut64 from, const ut8 *buf, int len
|
||||
} else {
|
||||
/* wide char check \x??\x00\x??\x00 */
|
||||
if (matches && i + 2 < len && buf[i+2]=='\0' && buf[i]=='\0' && buf[i+1]!='\0') {
|
||||
widechar = 1;
|
||||
// widechar = 1;
|
||||
return 1; // widechar
|
||||
}
|
||||
/* check if the length fits on our request */
|
||||
|
@ -171,7 +171,10 @@ R_API RBuffer *r_buf_new_sparse(ut8 Oxff) {
|
||||
}
|
||||
|
||||
R_API RBuffer *r_buf_new_slice(RBuffer *b, ut64 offset, ut64 size) {
|
||||
if (b && b->sparse) {
|
||||
if (!b) {
|
||||
return NULL;
|
||||
}
|
||||
if (b->sparse) {
|
||||
eprintf ("r_buf_new_slice not supported yet for sparse buffers\n");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -147,6 +147,9 @@ int ar_read_file(RBuffer *b, char *buffer, bool lookup, RList *files, const char
|
||||
// Re-read the whole filename
|
||||
b->cur -= dif;
|
||||
r = ar_read (b, buffer, AR_FILENAME_LEN);
|
||||
if (r != AR_FILENAME_LEN) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
free (curfile);
|
||||
curfile = strdup (buffer);
|
||||
@ -219,6 +222,9 @@ int ar_read_filename_table(RBuffer *b, char *buffer, RList *files, const char *f
|
||||
/* Read table size */
|
||||
b->cur += 32;
|
||||
r = ar_read (b, buffer, 10);
|
||||
if (r != 10) {
|
||||
return 0;
|
||||
}
|
||||
ut64 tablesize = strtoull (buffer, NULL, 10);
|
||||
|
||||
/* Header end */
|
||||
|
@ -184,6 +184,9 @@ int gdbr_connect(libgdbr_t *g, const char *host, int port) {
|
||||
}
|
||||
read_packet (g, false);
|
||||
ret = send_ack (g);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
if (strcmp (g->data, "OK")) {
|
||||
// return -1;
|
||||
}
|
||||
|
@ -1094,7 +1094,7 @@ static grub_err_t
|
||||
grub_hfs_open (struct grub_file *file, const char *name)
|
||||
{
|
||||
struct grub_hfs_data *data;
|
||||
struct grub_hfs_filerec frec;
|
||||
struct grub_hfs_filerec frec = {0};
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
|
||||
|
@ -547,7 +547,6 @@ R_API char *r_bin_java_unmangle_method(const char *flags, const char *name, cons
|
||||
r_val_str = strdup ("UNKNOWN");
|
||||
}
|
||||
f_val_str = strdup (flags ? flags : "");
|
||||
params_idx = 0;
|
||||
r_list_foreach (the_list, iter, str) {
|
||||
params_len += strlen (str);
|
||||
if (params_idx > 0) {
|
||||
@ -970,60 +969,57 @@ R_API int extract_type_value(const char *arg_str, char **output) {
|
||||
R_FREE (*output);
|
||||
}
|
||||
while (arg_str && *arg_str && !found_one) {
|
||||
len = 0;
|
||||
len = 1;
|
||||
// handle the end of an object
|
||||
switch (*arg_str) {
|
||||
case 'V':
|
||||
len = 1;
|
||||
str = get_type_value_str ("void", array_cnt);
|
||||
break;
|
||||
case 'J':
|
||||
len = 1;
|
||||
str = get_type_value_str ("long", array_cnt);
|
||||
array_cnt = 0;
|
||||
break;
|
||||
case 'I':
|
||||
len = 1;
|
||||
str = get_type_value_str ("int", array_cnt);
|
||||
array_cnt = 0;
|
||||
break;
|
||||
case 'D':
|
||||
len = 1;
|
||||
str = get_type_value_str ("double", array_cnt);
|
||||
array_cnt = 0;
|
||||
break;
|
||||
case 'F':
|
||||
len = 1;
|
||||
str = get_type_value_str ("float", array_cnt);
|
||||
array_cnt = 0;
|
||||
break;
|
||||
case 'B':
|
||||
len = 1;
|
||||
str = get_type_value_str ("byte", array_cnt);
|
||||
array_cnt = 0;
|
||||
break;
|
||||
case 'C':
|
||||
len = 1;
|
||||
str = get_type_value_str ("char", array_cnt);
|
||||
array_cnt = 0;
|
||||
break;
|
||||
case 'Z':
|
||||
len = 1;
|
||||
str = get_type_value_str ("boolean", array_cnt);
|
||||
array_cnt = 0;
|
||||
break;
|
||||
case 'S':
|
||||
len = 1;
|
||||
str = get_type_value_str ("short", array_cnt);
|
||||
array_cnt = 0;
|
||||
break;
|
||||
case '[': len = 1; array_cnt++; break;
|
||||
case '[':
|
||||
array_cnt++;
|
||||
break;
|
||||
case 'L':
|
||||
len = r_bin_java_extract_reference_name (arg_str, &str, array_cnt);
|
||||
array_cnt = 0;
|
||||
break;
|
||||
case '(': len = 1; str = strdup ("("); break;
|
||||
case ')': len = 1; str = strdup (")"); break;
|
||||
case '(':
|
||||
str = strdup ("(");
|
||||
break;
|
||||
case ')':
|
||||
str = strdup (")");
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ DsoJsonObj * dso_json_dict_new () {
|
||||
DsoJsonObj *x = dso_json_null_new ();
|
||||
if (x) {
|
||||
x->info = get_type_info (DSO_JSON_DICT);
|
||||
x->val._dict = calloc (sizeof (DsoJsonObj), 1);
|
||||
x->val._dict = calloc (sizeof (DsoJsonDict), 1);
|
||||
if (!x->val._dict) {
|
||||
dso_json_null_free (x);
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user