From c20754c4a65784f46519397cee285018670d2cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 4 Mar 2019 18:52:56 +0100 Subject: [PATCH] Fix Coverity Scan false positive --- src/cocoa_joystick.m | 2 +- src/input.c | 2 +- src/win32_joystick.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index 1c2818f0..23cc7a8e 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -464,7 +464,7 @@ void _glfwPlatformUpdateGamepadGUID(char* guid) (strncmp(guid + 20, "000000000000", 12) == 0)) { char original[33]; - strcpy(original, guid); + strncpy(original, guid, sizeof(original) - 1); sprintf(guid, "03000000%.4s0000%.4s000000000000", original, original + 16); } diff --git a/src/input.c b/src/input.c index b5e11542..7ee42811 100644 --- a/src/input.c +++ b/src/input.c @@ -436,7 +436,7 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name, js->buttonCount = buttonCount; js->hatCount = hatCount; - strcpy(js->guid, guid); + strncpy(js->guid, guid, sizeof(js->guid) - 1); js->mapping = findValidMapping(js); return js; diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 58123965..280ab477 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -745,7 +745,7 @@ void _glfwPlatformUpdateGamepadGUID(char* guid) if (strcmp(guid + 20, "504944564944") == 0) { char original[33]; - strcpy(original, guid); + strncpy(original, guid, sizeof(original) - 1); sprintf(guid, "03000000%.4s0000%.4s000000000000", original, original + 4); }