1
0
mirror of https://github.com/libretro/RetroArch synced 2025-03-26 11:37:30 +00:00

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

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

@ -603,13 +603,11 @@ static void menu_action_setting_disp_set_label_input_desc(
remap_idx = remap_idx =
settings->uints.input_remap_ids[user_idx][btn_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) if (!system)
return; return;
if (remap_idx != RARCH_UNMAPPED)
descriptor = system->input_desc_btn[user_idx][remap_idx]; descriptor = system->input_desc_btn[user_idx][remap_idx];
if (!string_is_empty(descriptor) && remap_idx < RARCH_FIRST_CUSTOM_BIND) if (!string_is_empty(descriptor) && remap_idx < RARCH_FIRST_CUSTOM_BIND)

@ -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 /* 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 */ 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) /*|| 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)*/) (remap_idx >= RARCH_FIRST_CUSTOM_BIND && remap_idx < RARCH_CUSTOM_BIND_LIST_END)*/)
action_left_input_desc(type, label, wraparound); action_left_input_desc(type, label, wraparound);
}
return 0; return 0;
} }

@ -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 /* 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 */ 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) /*|| 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)*/) (remap_idx >= RARCH_FIRST_CUSTOM_BIND && remap_idx < RARCH_CUSTOM_BIND_LIST_END)*/)
action_right_input_desc(type, label, wraparound); action_right_input_desc(type, label, wraparound);
}
#if 0 #if 0
int i = 0; int i = 0;