prevent out of bound array access for unmapped input binds

This commit is contained in:
Brad Parker 2018-09-15 01:21:03 -04:00
parent 09d27fc591
commit 19329fe7c7
4 changed files with 36 additions and 28 deletions

View File

@ -221,15 +221,19 @@ void input_mapper_poll(input_mapper_t *handle)
else
{
int invert = 1;
unsigned remap_axis_bind = remap_axis - RARCH_FIRST_CUSTOM_BIND;
if ( (k % 2 == 0 && remap_axis % 2 != 0) ||
(k % 2 != 0 && remap_axis % 2 == 0)
)
invert = -1;
if (remap_axis_bind < sizeof(handle->analog_value[i]))
{
handle->analog_value[i][
remap_axis - RARCH_FIRST_CUSTOM_BIND] =
remap_axis_bind] =
current_axis_value * invert;
}
#if 0
RARCH_LOG("axis %d(%d) remapped to axis %d val %d\n",
j, k,

View File

@ -603,13 +603,11 @@ static void menu_action_setting_disp_set_label_input_desc(
remap_idx =
settings->uints.input_remap_ids[user_idx][btn_idx];
/*
if (remap_idx == RARCH_UNMAPPED)
settings->uints.input_remap_ids[user_idx][btn_idx] = RARCH_UNMAPPED;
*/
if (!system)
return;
if (remap_idx != RARCH_UNMAPPED)
descriptor = system->input_desc_btn[user_idx][remap_idx];
if (!string_is_empty(descriptor) && remap_idx < RARCH_FIRST_CUSTOM_BIND)

View File

@ -385,9 +385,12 @@ static int action_left_input_desc(unsigned type, const char *label,
/* skip the not used buttons (unless they are at the end by calling the right desc function recursively
also skip all the axes until analog remapping is implemented */
if (remap_idx != RARCH_UNMAPPED)
{
if ((string_is_empty(system->input_desc_btn[user_idx][remap_idx]) && remap_idx < RARCH_CUSTOM_BIND_LIST_END) /*||
(remap_idx >= RARCH_FIRST_CUSTOM_BIND && remap_idx < RARCH_CUSTOM_BIND_LIST_END)*/)
action_left_input_desc(type, label, wraparound);
}
return 0;
}

View File

@ -157,9 +157,12 @@ int action_right_input_desc(unsigned type, const char *label,
/* skip the not used buttons (unless they are at the end by calling the right desc function recursively
also skip all the axes until analog remapping is implemented */
if (remap_idx != RARCH_UNMAPPED)
{
if ((string_is_empty(system->input_desc_btn[user_idx][remap_idx]) && remap_idx < RARCH_CUSTOM_BIND_LIST_END) /*||
(remap_idx >= RARCH_FIRST_CUSTOM_BIND && remap_idx < RARCH_CUSTOM_BIND_LIST_END)*/)
action_right_input_desc(type, label, wraparound);
}
#if 0
int i = 0;