sprintf -> snprintf

This commit is contained in:
Kovid Goyal
2023-11-16 15:14:30 +05:30
parent 0cd761808a
commit 0f60ac2dd7

View File

@@ -169,14 +169,14 @@ static void matchCallback(void* context UNUSED,
// Generate a joystick GUID that matches the SDL 2.0.5+ one
if (vendor && product)
{
sprintf(guid, "03000000%02x%02x0000%02x%02x0000%02x%02x0000",
snprintf(guid, sizeof(guid), "03000000%02x%02x0000%02x%02x0000%02x%02x0000",
(uint8_t) vendor, (uint8_t) (vendor >> 8),
(uint8_t) product, (uint8_t) (product >> 8),
(uint8_t) version, (uint8_t) (version >> 8));
}
else
{
sprintf(guid, "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
snprintf(guid, sizeof(guid), "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
name[0], name[1], name[2], name[3],
name[4], name[5], name[6], name[7],
name[8], name[9], name[10]);
@@ -476,7 +476,7 @@ void _glfwPlatformUpdateGamepadGUID(char* guid)
{
char original[33];
strncpy(original, guid, sizeof(original) - 1);
sprintf(guid, "03000000%.4s0000%.4s000000000000",
snprintf(guid, 33, "03000000%.4s0000%.4s000000000000",
original, original + 16);
}
}