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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/platform/x11/x11_hotplug_event_handler.h" 5 #include "ui/events/platform/x11/x11_hotplug_event_handler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <X11/extensions/XInput.h> 8 #include <X11/extensions/XInput.h>
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #include <X11/Xatom.h> 10 #include <X11/Xatom.h>
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // e.g. Device Node (250): "/dev/input/event8" 208 // e.g. Device Node (250): "/dev/input/event8"
209 Atom device_node = XInternAtom(dpy, "Device Node", False); 209 Atom device_node = XInternAtom(dpy, "Device Node", False);
210 if (device_node == None) 210 if (device_node == None)
211 return base::FilePath(); 211 return base::FilePath();
212 212
213 Atom actual_type; 213 Atom actual_type;
214 int actual_format; 214 int actual_format;
215 unsigned long nitems, bytes_after; 215 unsigned long nitems, bytes_after;
216 unsigned char* data; 216 unsigned char* data;
217 XDevice* dev = XOpenDevice(dpy, device.deviceid); 217 XDevice* dev = XOpenDevice(dpy, device.deviceid);
218 if (!dev) 218
219 // Sometimes XOpenDevice() doesn't return null but the contents aren't valid.
220 // Calling XGetDeviceProperty() when dev->device_id is invalid triggers a
221 // BadDevice error. Return early to avoid a crash. http://crbug.com/659261
222 if (!dev || dev->device_id != base::checked_cast<XID>(device.deviceid))
219 return base::FilePath(); 223 return base::FilePath();
220 224
221 if (XGetDeviceProperty(dpy, 225 if (XGetDeviceProperty(dpy,
222 dev, 226 dev,
223 device_node, 227 device_node,
224 0, 228 0,
225 1000, 229 1000,
226 False, 230 False,
227 AnyPropertyType, 231 AnyPropertyType,
228 &actual_type, 232 &actual_type,
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 // worker thread. Once the device information is extracted the parsed devices 497 // worker thread. Once the device information is extracted the parsed devices
494 // will be returned via the callbacks. 498 // will be returned via the callbacks.
495 base::WorkerPool::PostTask( 499 base::WorkerPool::PostTask(
496 FROM_HERE, 500 FROM_HERE,
497 base::Bind(&HandleHotplugEventInWorker, device_infos, display_state, 501 base::Bind(&HandleHotplugEventInWorker, device_infos, display_state,
498 base::ThreadTaskRunnerHandle::Get(), callbacks), 502 base::ThreadTaskRunnerHandle::Get(), callbacks),
499 true /* task_is_slow */); 503 true /* task_is_slow */);
500 } 504 }
501 505
502 } // namespace ui 506 } // namespace ui
OLDNEW
« 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