Fix #2841 - Fix some near-infinite loops in sandbox mode

This commit is contained in:
pancake 2015-06-25 23:41:14 +02:00
parent 6dc29e516a
commit e3e39a806e
2 changed files with 16 additions and 3 deletions

View File

@ -1414,7 +1414,12 @@ static void do_string_search(RCore *core, struct search_parameters *param) {
if (!json) {
eprintf ("# %d [0x%"PFMT64x"-0x%"PFMT64x"]\n", fd, param->from, param->to);
}
if (r_sandbox_enable (0)) {
if ((param->to - param->from) > 1024*64) {
eprintf ("Sandbox restricts search range\n");
break;
}
}
if (param->bckwrds) {
if (param->to < param->from + bufsz) {
at = param->from;
@ -2107,7 +2112,7 @@ static int cmd_search(void *data, const char *input) {
searchhits = 0;
r_config_set_i (core->config, "search.kwidx", core->search->n_kws);
if (dosearch)
do_string_search(core, &param);
do_string_search (core, &param);
beach:
core->num->value = searchhits;
core->in_search = R_FALSE;

View File

@ -1092,9 +1092,17 @@ R_API int r_core_prompt_exec(RCore *r) {
R_API int r_core_block_size(RCore *core, int bsize) {
ut8 *bump;
int ret = R_FALSE;
if (bsize<0) return R_FALSE;
if (bsize == core->blocksize)
return R_TRUE;
if (bsize<0 || bsize > core->blocksize_max) {
if (r_sandbox_enable (0)) {
// TODO : restrict to filesize?
if (bsize > 1024*32) {
eprintf ("Sandbox mode restricts blocksize bigger than 32k\n");
return R_FALSE;
}
}
if (bsize > core->blocksize_max) {
eprintf ("Block size %d is too big\n", bsize);
return R_FALSE;
}