Fix #21438 - Do not permit negative arguments to /z

This commit is contained in:
pancake 2023-03-06 14:22:58 +01:00
parent b673677a81
commit 08e51ab484
2 changed files with 10 additions and 2 deletions

View File

@ -4866,14 +4866,21 @@ again:
eprintf ("Usage: /z min max\n");
break;
}
const char *maxstr = NULL;
if ((p = strchr (input + 2, ' '))) {
*p = 0;
max = r_num_math (core->num, p + 1);
maxstr = r_str_trim_head_ro (p + 1);
max = r_num_math (core->num, maxstr);
} else {
eprintf ("Usage: /z min max\n");
break;
}
min = r_num_math (core->num, input + 2);
const char *minstr = r_str_trim_head_ro (input + 2);
if ((maxstr && *maxstr == '-') || (minstr && *minstr == '-')) {
R_LOG_ERROR ("min and max must be positive");
break;
}
min = r_num_math (core->num, minstr);
if (!r_search_set_string_limits (core->search, min, max)) {
R_LOG_ERROR ("min must be lower than max");
break;

View File

@ -14,6 +14,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
return 0;
}
r_core_cmd0 (r, "e scr.interactive=false");
// r_core_cmdf (r, "o malloc://%zu", Size);
// r_io_write_at (r->io, 0, Data, Size);
r_core_cmd0 (r, "o /bin/ls");