From 88935f701f51d84ed536cb55cc7b2ba391d7597e Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Mon, 9 May 2011 10:24:18 +0200 Subject: console: Fix 'event send' handling. This patch fixes two bugs in the implementation of the 'event send' command: 1/ It prevents a crash when using the '0:0:0' event triple (note that the equivalent EV_SYNC:0:0 used in testing didn't crash) 2/ If fixes the parser to correctly handle several event triples on the same line, as in: event send :: :: ... Change-Id: I26cb55dd2feb75fda4f50ba0d49c7c8ad8a9dcca --- android/console.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'android/console.c') diff --git a/android/console.c b/android/console.c index 505d331..daae2d7 100644 --- a/android/console.c +++ b/android/console.c @@ -1854,9 +1854,10 @@ do_event_send( ControlClient client, char* args ) p = args; while (*p) { char* q; + char temp[128]; int type, code, value, ret; - p += strspn( args, " \t" ); /* skip spaces */ + p += strspn( p, " \t" ); /* skip spaces */ if (*p == 0) break; @@ -1865,7 +1866,8 @@ do_event_send( ControlClient client, char* args ) if (q == p) break; - ret = android_event_from_str( p, &type, &code, &value ); + snprintf(temp, sizeof temp, "%.*s", q-p, p); + ret = android_event_from_str( temp, &type, &code, &value ); if (ret < 0) { if (ret == -1) { control_write( client, -- cgit v1.1