mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-14 08:49:50 +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;
|
return R_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (searchshow) {
|
if (searchshow && kw && kw->keyword_length > 0) {
|
||||||
int len, i;
|
int len, i;
|
||||||
ut8 buf[64];
|
ut32 buf_sz = kw->keyword_length;
|
||||||
char str[128], *p;
|
ut8 *buf = malloc (buf_sz);
|
||||||
|
char *str = NULL, *p = NULL;
|
||||||
switch (kw->type) {
|
switch (kw->type) {
|
||||||
case R_SEARCH_KEYWORD_TYPE_STRING:
|
case R_SEARCH_KEYWORD_TYPE_STRING:
|
||||||
len = sizeof (str);
|
str = malloc (kw->keyword_length + 20);
|
||||||
r_core_read_at (core, addr, (ut8*)str+1, len-2);
|
r_core_read_at (core, addr, (ut8*)str+1, kw->keyword_length);
|
||||||
*str = '"';
|
*str = '"';
|
||||||
r_str_filter_zeroline (str, len);
|
r_str_filter_zeroline (str, kw->keyword_length+1);
|
||||||
strcpy (str+strlen (str), "\"");
|
strcpy (str+kw->keyword_length+1, "\"");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
len = kw->keyword_length + 8; // 8 byte context
|
len = kw->keyword_length; // 8 byte context
|
||||||
if (len>=sizeof (str)) len = sizeof (str)-1;
|
str = malloc (len);
|
||||||
r_core_read_at (core, addr, buf, sizeof (buf));
|
memset (str, 0, len);
|
||||||
|
r_core_read_at (core, addr, buf, kw->keyword_length);
|
||||||
for (i=0, p=str; i<len; i++) {
|
for (i=0, p=str; i<len; i++) {
|
||||||
sprintf (p, "%02x", buf[i]);
|
sprintf (p, "%02x", buf[i]);
|
||||||
p += 2;
|
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",
|
r_cons_printf ("0x%08"PFMT64x" %s%d_%d %s\n",
|
||||||
addr, searchprefix, kw->kwidx, kw->count, str);
|
addr, searchprefix, kw->kwidx, kw->count, str);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
free (str);
|
||||||
} else {
|
} else {
|
||||||
if (searchflags)
|
if (searchflags)
|
||||||
r_cons_printf ("%s%d_%d\n", searchprefix, kw->kwidx, kw->count);
|
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) {
|
static int r_cmd_java_handle_reload_bin (RCore *core, const char *cmd) {
|
||||||
RAnal *anal = get_anal (core);
|
RAnal *anal = get_anal (core);
|
||||||
RBinJavaObj *obj = (RBinJavaObj *) r_cmd_java_get_bin_obj (anal);
|
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 cur_offset = core->offset, addr = 0;
|
||||||
ut64 buf_size = 0;
|
ut64 buf_size = 0;
|
||||||
ut8 * buf = NULL;
|
ut8 * buf = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user