Limit aap scan like we do for strings. (#3620)

This commit is contained in:
Giovanni 2023-07-02 01:14:12 +08:00 committed by GitHub
parent 54640cb01c
commit 366dfcfbf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -2936,6 +2936,7 @@ RZ_API int rz_core_config_init(RzCore *core) {
update_analysis_arch_options(core, n);
SETCB("analysis.cpu", RZ_SYS_ARCH, &cb_analysis_cpu, "Specify the analysis.cpu to use");
SETPREF("analysis.prelude", "", "Specify an hexpair to find preludes in code");
SETI("analysis.prelude.limit", 1024 * 1024 * 20, "Maximum size of the range to scan for preludes");
SETCB("analysis.recont", "false", &cb_analysis_recont, "End block after splitting a basic block instead of error"); // testing
SETCB("analysis.jmp.indir", "false", &cb_analysis_ijmp, "Follow the indirect jumps in function analysis"); // testing
SETI("analysis.ptrdepth", 3, "Maximum number of nested pointers to follow in analysis");

View file

@ -335,6 +335,7 @@ RZ_API int rz_core_search_preludes(RzCore *core, bool log) {
ut8 *keyword = NULL;
const char *prelude = rz_config_get(core->config, "analysis.prelude");
const char *where = rz_config_get(core->config, "analysis.in");
ut64 limit = rz_config_get_i(core->config, "analysis.prelude.limit");
RzList *list = rz_core_get_boundaries_prot(core, RZ_PERM_X, where, "search");
RzList *arch_preludes = NULL;
@ -368,6 +369,12 @@ RZ_API int rz_core_search_preludes(RzCore *core, bool log) {
}
from = p->itv.addr;
to = rz_itv_end(p->itv);
if ((to - from) >= limit) {
RZ_LOG_WARN("aap: search interval (from 0x%" PFMT64x
" to 0x%" PFMT64x ") exeeds analysis.prelude.limit (0x%" PFMT64x "), skipping it.\n",
from, to, limit);
continue;
}
if (keyword && keyword_length > 0) {
ret = rz_core_search_prelude(core, from, to, keyword, keyword_length, NULL, 0);
} else {