Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(848)

Unified Diff: ui/events/platform/x11/x11_hotplug_event_handler.cc

Issue 2471653002: Check that XOpenDevice() returns valid device_id. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/platform/x11/x11_hotplug_event_handler.cc
diff --git a/ui/events/platform/x11/x11_hotplug_event_handler.cc b/ui/events/platform/x11/x11_hotplug_event_handler.cc
index b05de3c33236ecbb82542c40d9d65ed768b4ebf5..be7bb0911d20c6c3339396ab3d825d17f26f1f8e 100644
--- a/ui/events/platform/x11/x11_hotplug_event_handler.cc
+++ b/ui/events/platform/x11/x11_hotplug_event_handler.cc
@@ -215,7 +215,11 @@ base::FilePath GetDevicePath(XDisplay* dpy, const XIDeviceInfo& device) {
unsigned long nitems, bytes_after;
unsigned char* data;
XDevice* dev = XOpenDevice(dpy, device.deviceid);
- if (!dev)
+
+ // Sometimes XOpenDevice() doesn't return null but the contents aren't valid.
+ // Calling XGetDeviceProperty() when dev->device_id is invalid triggers a
+ // BadDevice error. Return early to avoid a crash. http://crbug.com/659261
+ if (!dev || dev->device_id != base::checked_cast<XID>(device.deviceid))
return base::FilePath();
if (XGetDeviceProperty(dpy,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698