浏览代码

Fix potential gamepad name string copy overflow

pull/4696/head
asdqwe 16 小时前
父节点
当前提交
72ad7edcae
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. +2
    -2
      src/platforms/rcore_desktop_glfw.c

+ 2
- 2
src/platforms/rcore_desktop_glfw.c 查看文件

@ -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));
}
//----------------------------------------------------------------------------
@ -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)
{

正在加载...
取消
保存