From 72ad7edcaee4f5ad47d36f8c6f54b76d39eee753 Mon Sep 17 00:00:00 2001 From: asdqwe Date: Fri, 17 Jan 2025 08:32:54 -0300 Subject: [PATCH] Fix potential gamepad name string copy overflow --- src/platforms/rcore_desktop_glfw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index dba821ddd..856ac3708 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/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) {