Skip to content

Commit

Permalink
Prevent more than DIM_TOUCH simultaneous touches
Browse files Browse the repository at this point in the history
If more than DIM_TOUCH simtulataneous touches are received, the evdev
and xi2 backends will attempt to store data for the touch beyond the
end of the touches array, potentially resulting in a segfault.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
jigpu authored and whot committed May 15, 2014
1 parent 0400989 commit c7cc2d7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tools/mtview.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,12 @@ static void handle_abs_event(struct input_event *ev, struct touch_info *touch_in
touch_info->touches[slot].active = (ev->value != -1);
break;
case ABS_MT_SLOT:
touch_info->current_slot = ev->value;
slot = touch_info->current_slot;
slot = ev->value;
if (ev->value >= DIM_TOUCH) {
msg("Too many simultaneous touches.\n");
slot = -1;
}
touch_info->current_slot = slot;
break;
}
if (slot == -1)
Expand Down Expand Up @@ -686,6 +690,11 @@ static void handle_xi2_event(Display *dpy, XEvent *e, struct touch_info *ti)
break;
}

if (i == ti->ntouches) {
msg("Too many simultaneous touches. Ignoring most-recent new contact.\n");
return;
}

/* store tracking ID in active */
ti->touches[i].active = (ev->evtype != XI_TouchEnd);
ti->touches[i].data[ABS_MT_POSITION_X] = ev->root_x;
Expand Down

0 comments on commit c7cc2d7

Please sign in to comment.