diff --git a/README.md b/README.md index c53173d2..90729f3b 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Gamma ramp setting via RandR did not validate ramp size - [X11] Bugfix: Key name string encoding depended on current locale (#981,#983) - [Linux] Bugfix: Event processing did not detect joystick disconnection (#932) +- [Linux] Bugfix: The joystick device path could be truncated (#1025) - [Cocoa] Added support for Vulkan window surface creation via [MoltenVK](https://moltengl.com/moltenvk/) (#870) - [Cocoa] Added support for loading a `MainMenu.nib` when available diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 6e4b6a8c..da6c490d 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -160,15 +160,24 @@ GLFWbool _glfwInitJoysticksLinux(void) while ((entry = readdir(dir))) { - char path[20]; regmatch_t match; + char* path = NULL; if (regexec(&_glfw.linjs.regex, entry->d_name, 1, &match, 0) != 0) continue; - snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name); + if (asprintf(&path, "%s/%s", dirname, entry->d_name) < 0) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Linux: Failed to construct device path: %s", + strerror(errno)); + continue; + } + if (openJoystickDevice(path)) count++; + + free(path); } closedir(dir);