Honor rabin2 -N minstrlen for -z,-zz,-zzz
This commit is contained in:
parent
131b9092c2
commit
e807868b78
|
@ -476,8 +476,7 @@ int main(int argc, char **argv) {
|
|||
break;
|
||||
case '@': at = r_num_math (NULL, optarg); break;
|
||||
case 'n': name = optarg; break;
|
||||
case 'N':
|
||||
{
|
||||
case 'N': {
|
||||
char *q, *p = strdup (optarg);
|
||||
q = strchr (p, ':');
|
||||
if (q) {
|
||||
|
@ -487,8 +486,7 @@ int main(int argc, char **argv) {
|
|||
r_config_set (core.config, "bin.minstr", optarg);
|
||||
}
|
||||
free (p);
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
//case 'V': return blob_version ("rabin2");
|
||||
case 'h':
|
||||
r_core_fini (&core);
|
||||
|
@ -570,6 +568,7 @@ int main(int argc, char **argv) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
bin->minstrlen = r_config_get_i (core.config, "bin.minstr");
|
||||
if (!r_bin_load (bin, file, laddr, 0, xtr_idx, fd, rawstr)) {
|
||||
if (!r_bin_load (bin, file, laddr, 0, xtr_idx, fd, rawstr)) {
|
||||
eprintf ("r_bin: Cannot open file\n");
|
||||
|
@ -579,7 +578,6 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
if (rawstr == 2) {
|
||||
rawstr = R_FALSE;
|
||||
bin->minstrlen = r_config_get_i (core.config, "bin.minstr");
|
||||
r_bin_dump_strings (core.bin->cur, bin->minstrlen);
|
||||
}
|
||||
|
||||
|
@ -667,7 +665,7 @@ int main(int argc, char **argv) {
|
|||
if (action&x) {\
|
||||
if (isradjson) r_cons_printf ("\"%s\":",n);\
|
||||
if (!r_core_bin_info (&core, y, rad, va, &filter, laddr, chksum)) {\
|
||||
if (isradjson) r_cons_printf("false");\
|
||||
if (isradjson) r_cons_printf ("false");\
|
||||
};\
|
||||
actions_done++;\
|
||||
if (isradjson) r_cons_printf (actions==actions_done? "":",");\
|
||||
|
|
|
@ -213,8 +213,10 @@ static void get_strings_range(RBinFile *arch, RList *list, int min, ut64 from, u
|
|||
if (min == 0)
|
||||
min = plugin? plugin->minstrlen: 4;
|
||||
|
||||
#if 0
|
||||
if (arch->rawstr == R_TRUE)
|
||||
min = 1;
|
||||
#endif
|
||||
|
||||
/* Some plugins return zero, fix it up */
|
||||
if (min == 0)
|
||||
|
@ -347,7 +349,11 @@ static int r_bin_object_set_items(RBinFile *binfile, RBinObject *o) {
|
|||
if (!binfile || !o || !o->plugin) return R_FALSE;
|
||||
|
||||
cp = o->plugin;
|
||||
minlen = cp->minstrlen;
|
||||
if (binfile->rbin->minstrlen>0) {
|
||||
minlen = binfile->rbin->minstrlen;
|
||||
} else {
|
||||
minlen = cp->minstrlen;
|
||||
}
|
||||
binfile->o = o;
|
||||
if (cp->baddr) o->baddr = cp->baddr (binfile);
|
||||
o->loadaddr = o->baddr;
|
||||
|
@ -1190,7 +1196,7 @@ R_API RBin* r_bin_new() {
|
|||
bin->printf = (PrintfCallback)printf;
|
||||
bin->plugins = r_list_new();
|
||||
bin->plugins->free = free;
|
||||
bin->minstrlen = -2;
|
||||
bin->minstrlen = 0;
|
||||
bin->cur = NULL;
|
||||
|
||||
bin->binfiles = r_list_newf ((RListFree)r_bin_file_free);
|
||||
|
@ -1673,7 +1679,8 @@ R_API int r_bin_file_set_cur_binfile_obj (RBin * bin, RBinFile *bf, RBinObject *
|
|||
bin->narch = bf->narch;
|
||||
bf->o = obj;
|
||||
plugin = r_bin_file_cur_plugin (bf);
|
||||
bin->minstrlen = plugin ? plugin->minstrlen : bin->minstrlen;
|
||||
if (bin->minstrlen <1)
|
||||
bin->minstrlen = plugin ? plugin->minstrlen : bin->minstrlen;
|
||||
r_bin_object_set_sections (bf, obj);
|
||||
return R_TRUE;
|
||||
|
||||
|
|
|
@ -146,6 +146,9 @@ typedef struct r_bin_file_t {
|
|||
RBinObject *o;
|
||||
void *xtr_obj;
|
||||
ut64 loadaddr;
|
||||
/* values used when searching the strings */
|
||||
int minstrlen;
|
||||
int maxstrlen;
|
||||
int narch;
|
||||
struct r_bin_xtr_plugin_t *curxtr;
|
||||
struct r_bin_plugin_t *curplugin;
|
||||
|
@ -161,6 +164,7 @@ typedef struct r_bin_t {
|
|||
RBinFile *cur;
|
||||
int narch;
|
||||
void *user;
|
||||
/* preconfigured values */
|
||||
int minstrlen;
|
||||
int maxstrlen;
|
||||
int rawstr;
|
||||
|
@ -238,6 +242,7 @@ typedef struct r_bin_plugin_t {
|
|||
int (*get_offset)(RBinFile *arch, int type, int idx);
|
||||
ut64 (*get_vaddr)(RBinFile *arch, ut64 baddr, ut64 paddr, ut64 vaddr);
|
||||
RBuffer* (*create)(RBin *bin, const ut8 *code, int codelen, const ut8 *data, int datalen);
|
||||
/* default value if not specified by user */
|
||||
int minstrlen;
|
||||
void *user;
|
||||
} RBinPlugin;
|
||||
|
|
Loading…
Reference in New Issue