Fix Coverity Scan false positive

From upstream: c20754c4a6
This commit is contained in:
Kovid Goyal
2019-03-06 08:40:02 +05:30
parent aa2b21456f
commit db16996181
3 changed files with 3 additions and 4 deletions

View File

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

2
glfw/input.c vendored
View File

@@ -415,7 +415,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;

View File

@@ -743,9 +743,8 @@ 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);
}
}