Skip to content

Commit

Permalink
Fix potential gamepad name string copy overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
asdqwe committed Jan 17, 2025
1 parent 0275d13 commit 72ad7ed
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/platforms/rcore_desktop_glfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,7 @@ int InitPlatform(void)
// Retrieve gamepad names
for (int i = 0; i < MAX_GAMEPADS; i++)
{
if (glfwJoystickPresent(i)) strcpy(CORE.Input.Gamepad.name[i], glfwGetJoystickName(i));
if (glfwJoystickPresent(i)) snprintf(CORE.Input.Gamepad.name[i], sizeof(CORE.Input.Gamepad.name[i]), "%s", glfwGetJoystickName(i));
}
//----------------------------------------------------------------------------

Expand Down Expand Up @@ -1915,7 +1915,7 @@ static void JoystickCallback(int jid, int event)
{
if (event == GLFW_CONNECTED)
{
strcpy(CORE.Input.Gamepad.name[jid], glfwGetJoystickName(jid));
snprintf(CORE.Input.Gamepad.name[jid], sizeof(CORE.Input.Gamepad.name[jid]), "%s", glfwGetJoystickName(jid));
}
else if (event == GLFW_DISCONNECTED)
{
Expand Down

0 comments on commit 72ad7ed

Please sign in to comment.