debugger: Impose an arbitrary upper limit on the count parameter of the gni command to prevent denial of service

This commit is contained in:
AJR 2022-05-22 20:46:04 -04:00
parent c24dc4a0e1
commit 88dc7bcf92
2 changed files with 8 additions and 1 deletions

View File

@ -1382,12 +1382,18 @@ void debugger_commands::execute_go_branch(bool sense, const std::vector<std::str
void debugger_commands::execute_go_next_instruction(const std::vector<std::string> &params)
{
u64 count = 1;
static constexpr u64 MAX_COUNT = 512;
// if we have a parameter, use it instead */
if (params.size() > 0 && !validate_number_parameter(params[0], count))
return;
if (count == 0)
return;
if (count > MAX_COUNT)
{
m_console.printf("Too many instructions (must be %d or fewer)\n", MAX_COUNT);
return;
}
device_state_interface *stateintf;
device_t *cpu = m_machine.debugger().console().get_visible_cpu();

View File

@ -978,7 +978,8 @@ const help_item f_static_help_list[] =
"debugger until a breakpoint or watchpoint is hit, or until you manually break in using the "
"assigned key. Before executing, the gni command sets a temporary unconditional breakpoint "
"<count> instructions sequentially past the current one, which is automatically removed when "
"hit. If <count> is omitted, its default value is 1."
"hit. If <count> is omitted, its default value is 1. If <count> is specified as zero, the "
"command does nothing. <count> is not permitted to exceed 512 decimal."
"\n"
"Examples:\n"
"\n"