From 3a8032f49173c81c6f4ef860cf8ad7c2ff69e355 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_PrivateGameControllerParseControllerConfigString() (cherry picked from commit 312f98c2a1edaf9590fc06d10f201996c059d869) --- src/joystick/SDL_gamecontroller.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 7322674b8..4ce1c9118 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -1066,6 +1066,7 @@ static void SDL_PrivateGameControllerParseControllerConfigString(SDL_GameControl } else if (bGameButton) { if (i >= sizeof(szGameButton)) { + szGameButton[sizeof(szGameButton) - 1] = '\0'; SDL_SetError("Button name too large: %s", szGameButton); return; } @@ -1073,6 +1074,7 @@ static void SDL_PrivateGameControllerParseControllerConfigString(SDL_GameControl i++; } else { if (i >= sizeof(szJoystickButton)) { + szJoystickButton[sizeof(szJoystickButton) - 1] = '\0'; SDL_SetError("Joystick button name too large: %s", szJoystickButton); return; }