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

Side by Side Diff: ui/events/ozone/evdev/touch_event_converter_evdev.cc

Issue 891703004: Seeing crashes likely from negative touch indexes, check for them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months 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/ozone/evdev/touch_event_converter_evdev.h" 5 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <linux/input.h> 9 #include <linux/input.h>
10 #include <poll.h> 10 #include <poll.h>
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 ProcessInputEvent(inputs[i]); 163 ProcessInputEvent(inputs[i]);
164 } 164 }
165 } 165 }
166 166
167 void TouchEventConverterEvdev::ProcessInputEvent(const input_event& input) { 167 void TouchEventConverterEvdev::ProcessInputEvent(const input_event& input) {
168 if (input.type == EV_SYN) { 168 if (input.type == EV_SYN) {
169 ProcessSyn(input); 169 ProcessSyn(input);
170 } else if(syn_dropped_) { 170 } else if(syn_dropped_) {
171 // Do nothing. This branch indicates we have lost sync with the driver. 171 // Do nothing. This branch indicates we have lost sync with the driver.
172 } else if (input.type == EV_ABS) { 172 } else if (input.type == EV_ABS) {
173 if (current_slot_ >= MAX_FINGERS) { 173 if ((current_slot_ >= MAX_FINGERS || current_slot_ < 0) &&
174 LOG(ERROR) << "too many touch events: " << current_slot_; 174 input.code != ABS_MT_SLOT) {
spang 2015/02/02 19:22:00 Can't we keep the range check inside "case ABS_MT_
175 LOG(ERROR) << "invalid touch event index: " << current_slot_;
175 return; 176 return;
176 } 177 }
177 ProcessAbs(input); 178 ProcessAbs(input);
178 } else if (input.type == EV_KEY) { 179 } else if (input.type == EV_KEY) {
179 switch (input.code) { 180 switch (input.code) {
180 case BTN_TOUCH: 181 case BTN_TOUCH:
181 break; 182 break;
182 default: 183 default:
183 NOTIMPLEMENTED() << "invalid code for EV_KEY: " << input.code; 184 NOTIMPLEMENTED() << "invalid code for EV_KEY: " << input.code;
184 } 185 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 events_[current_slot_].finger_ = input.value; 217 events_[current_slot_].finger_ = input.value;
217 events_[current_slot_].type_ = ET_TOUCH_PRESSED; 218 events_[current_slot_].type_ = ET_TOUCH_PRESSED;
218 } 219 }
219 break; 220 break;
220 case ABS_MT_PRESSURE: 221 case ABS_MT_PRESSURE:
221 altered_slots_.set(current_slot_); 222 altered_slots_.set(current_slot_);
222 events_[current_slot_].pressure_ = input.value - pressure_min_; 223 events_[current_slot_].pressure_ = input.value - pressure_min_;
223 events_[current_slot_].pressure_ /= pressure_max_ - pressure_min_; 224 events_[current_slot_].pressure_ /= pressure_max_ - pressure_min_;
224 break; 225 break;
225 case ABS_MT_SLOT: 226 case ABS_MT_SLOT:
226 if (input.value >= MAX_FINGERS) {
227 LOG(ERROR) << "multi-touch slot " << input.value
228 << " exceeds MAX_FINGERS";
229 break;
230 }
231 current_slot_ = input.value; 227 current_slot_ = input.value;
232 altered_slots_.set(current_slot_);
233 break; 228 break;
234 default: 229 default:
235 DVLOG(5) << "unhandled code for EV_ABS: " << input.code; 230 DVLOG(5) << "unhandled code for EV_ABS: " << input.code;
236 } 231 }
237 } 232 }
238 233
239 void TouchEventConverterEvdev::ProcessSyn(const input_event& input) { 234 void TouchEventConverterEvdev::ProcessSyn(const input_event& input) {
240 switch (input.code) { 235 switch (input.code) {
241 case SYN_REPORT: 236 case SYN_REPORT:
242 if (syn_dropped_) { 237 if (syn_dropped_) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 281
287 // Subsequent events for this finger will be touch-move until it 282 // Subsequent events for this finger will be touch-move until it
288 // is released. 283 // is released.
289 events_[i].type_ = ET_TOUCH_MOVED; 284 events_[i].type_ = ET_TOUCH_MOVED;
290 } 285 }
291 } 286 }
292 altered_slots_.reset(); 287 altered_slots_.reset();
293 } 288 }
294 289
295 } // namespace ui 290 } // 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