From 312f98c2a1edaf9590fc06d10f201996c059d869 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Sat, 23 Dec 2023 21:30:09 +0100 Subject: [PATCH] Make sure the string is terminated, fixed invalid read in SDL_PrivateParseGamepadConfigString() --- src/joystick/SDL_gamepad.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c index c911183da8..e1e5b89f03 100644 --- a/src/joystick/SDL_gamepad.c +++ b/src/joystick/SDL_gamepad.c @@ -1282,12 +1282,14 @@ static int SDL_PrivateParseGamepadConfigString(SDL_Gamepad *gamepad, const char } else if (bGameButton) { if (i >= sizeof(szGameButton)) { + szGameButton[sizeof(szGameButton) - 1] = '\0'; return SDL_SetError("Button name too large: %s", szGameButton); } szGameButton[i] = *pchPos; i++; } else { if (i >= sizeof(szJoystickButton)) { + szJoystickButton[sizeof(szJoystickButton) - 1] = '\0'; return SDL_SetError("Joystick button name too large: %s", szJoystickButton); } szJoystickButton[i] = *pchPos;