[plasma/plasma-desktop] kcms/gamecontroller: kcms/gamecontroller: Fix UB to use of uninitialized memory
Sebastian Sauer <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 71b3e4dafaaab146d1054225bfaccf8115bebe2e by Sebastian Sauer.
Committed on 20/07/2026 at 04:29.
Pushed by meven into branch 'master'.
kcms/gamecontroller: Fix UB to use of uninitialized memory
In the else case sys_path was never initialized resulting
in random memory being passed into udev_device_new_from_syspath
what results in undefined behavior.
Based on a patch done by Adam Doda.
BUG: 522886
M +3 -0 kcms/gamecontroller/udevmatcher.cpp
https://invent.kde.org/plasma/plasma-desktop/-/commit/71b3e4dafaaab146d1054225bfaccf8115bebe2e
diff --git a/kcms/gamecontroller/udevmatcher.cpp b/kcms/gamecontroller/udevmatcher.cpp
index 24febd0291..08d4606db3 100644
--- a/kcms/gamecontroller/udevmatcher.cpp
+++ b/kcms/gamecontroller/udevmatcher.cpp
@@ -31,6 +31,9 @@ std::string UDevMatcher::deviceToUdevId(const std::string &device_path)
} else if (lastPart.starts_with("event")) {
// input devpaths end with eventXY
snprintf(sys_path, sizeof(sys_path), "/sys/class/input/%s", lastPart.c_str());
+ } else {
+ // Return empty if it doesn't match expected types
+ return devicePath;
}
std::unique_ptr<struct udev, decltype(&udev_unref)> udev(udev_new(), &udev_unref);
if (!udev) {