I get a compiler warning after updating gcc to 7.1.1 with -Wall.
https://github.com/glfw/glfw/blob/master/src/linux_joystick.c#L169
path length is set to 20 but can potentially contain 256 + length of dirname chars.
This is with 3.2.1 but I saw that this line hasn't changed so should still be valid.
Not sure if you try to get rid of warnings like that.
glfw/src/linux_joystick.c:224:46: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 19 [-Wformat-truncation=]
snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
glfw/src/linux_joystick.c:224:13: note: ‘snprintf’ output 2 or more bytes (assuming 257) into a destination of size 20
snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
Not sure if you try to get rid of warnings like that.
I do! Everything in -Wall, at least.
Awesome. I just fixed it locally by increasing the size to 512. But I don't have a joystick and no clue if that has side effects anywhere...
The proper solution will probably involve pathconf or asnprintf.
The issue is still there:
/home/dertarr/Downloads/glfw-3.2.1/src/linux_joystick.c: In function ‘_glfwInitJoysticksLinux’:
/home/dertarr/Downloads/glfw-3.2.1/src/linux_joystick.c:224:46: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 19 [-Wformat-truncation=]
snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
^~
/home/dertarr/Downloads/glfw-3.2.1/src/linux_joystick.c:224:13: note: ‘snprintf’ output 2 or more bytes (assuming 257) into a destination of size 20
snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@dertarr The patch above was applied after 3.2.1 was released.
Most helpful comment
The issue is still there: