From: Holger Schemel Date: Tue, 11 Jul 2017 20:57:32 +0000 (+0200) Subject: fixed and added some range checks for joysticks X-Git-Tag: 4.0.1.0~28 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=aa931ed885e278dc0102b5e10f59b2ba52fb690a;p=rocksndiamonds.git fixed and added some range checks for joysticks --- diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 04a098cd..04fa05e8 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -2603,7 +2603,7 @@ static boolean sdl_is_controller[MAX_PLAYERS]; static boolean SDLOpenJoystick(int nr) { - if (nr < 0 || nr > MAX_PLAYERS) + if (nr < 0 || nr >= MAX_PLAYERS) return FALSE; #if defined(TARGET_SDL2) @@ -2631,7 +2631,7 @@ static boolean SDLOpenJoystick(int nr) static void SDLCloseJoystick(int nr) { - if (nr < 0 || nr > MAX_PLAYERS) + if (nr < 0 || nr >= MAX_PLAYERS) return; #if 1 @@ -2659,7 +2659,7 @@ static void SDLCloseJoystick(int nr) boolean SDLCheckJoystickOpened(int nr) { - if (nr < 0 || nr > MAX_PLAYERS) + if (nr < 0 || nr >= MAX_PLAYERS) return FALSE; #if defined(TARGET_SDL2) @@ -2680,6 +2680,9 @@ static void setJoystickAxis(int nr, int axis_id_raw, int axis_value) int axis_id = axis_id_raw % 2; #endif + if (nr < 0 || nr >= MAX_PLAYERS) + return; + if (axis_id == -1) return; @@ -2723,6 +2726,9 @@ static void setJoystickButton(int nr, int button_id_raw, int button_state) int button_id = button_id_raw % 2; #endif + if (nr < 0 || nr >= MAX_PLAYERS) + return; + if (button_id == -1) return;