mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-14 16:59:08 +00:00
Fixing search static buffer and const-ifying non-const pointer
This commit is contained in:
parent
698fe42cfd
commit
7e60145d14
@ -90,22 +90,24 @@ static int __cb_hit(RSearchKeyword *kw, void *user, ut64 addr) {
|
||||
return R_FALSE;
|
||||
}
|
||||
}
|
||||
if (searchshow) {
|
||||
if (searchshow && kw && kw->keyword_length > 0) {
|
||||
int len, i;
|
||||
ut8 buf[64];
|
||||
char str[128], *p;
|
||||
ut32 buf_sz = kw->keyword_length;
|
||||
ut8 *buf = malloc (buf_sz);
|
||||
char *str = NULL, *p = NULL;
|
||||
switch (kw->type) {
|
||||
case R_SEARCH_KEYWORD_TYPE_STRING:
|
||||
len = sizeof (str);
|
||||
r_core_read_at (core, addr, (ut8*)str+1, len-2);
|
||||
str = malloc (kw->keyword_length + 20);
|
||||
r_core_read_at (core, addr, (ut8*)str+1, kw->keyword_length);
|
||||
*str = '"';
|
||||
r_str_filter_zeroline (str, len);
|
||||
strcpy (str+strlen (str), "\"");
|
||||
r_str_filter_zeroline (str, kw->keyword_length+1);
|
||||
strcpy (str+kw->keyword_length+1, "\"");
|
||||
break;
|
||||
default:
|
||||
len = kw->keyword_length + 8; // 8 byte context
|
||||
if (len>=sizeof (str)) len = sizeof (str)-1;
|
||||
r_core_read_at (core, addr, buf, sizeof (buf));
|
||||
len = kw->keyword_length; // 8 byte context
|
||||
str = malloc (len);
|
||||
memset (str, 0, len);
|
||||
r_core_read_at (core, addr, buf, kw->keyword_length);
|
||||
for (i=0, p=str; i<len; i++) {
|
||||
sprintf (p, "%02x", buf[i]);
|
||||
p += 2;
|
||||
@ -115,6 +117,9 @@ static int __cb_hit(RSearchKeyword *kw, void *user, ut64 addr) {
|
||||
}
|
||||
r_cons_printf ("0x%08"PFMT64x" %s%d_%d %s\n",
|
||||
addr, searchprefix, kw->kwidx, kw->count, str);
|
||||
|
||||
free (buf);
|
||||
free (str);
|
||||
} else {
|
||||
if (searchflags)
|
||||
r_cons_printf ("%s%d_%d\n", searchprefix, kw->kwidx, kw->count);
|
||||
|
@ -815,7 +815,7 @@ static int r_cmd_java_handle_replace_classname_value (RCore *core, const char *c
|
||||
static int r_cmd_java_handle_reload_bin (RCore *core, const char *cmd) {
|
||||
RAnal *anal = get_anal (core);
|
||||
RBinJavaObj *obj = (RBinJavaObj *) r_cmd_java_get_bin_obj (anal);
|
||||
char *p = cmd;
|
||||
const char *p = cmd;
|
||||
ut64 cur_offset = core->offset, addr = 0;
|
||||
ut64 buf_size = 0;
|
||||
ut8 * buf = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user