summaryrefslogtreecommitdiff
path: root/tools/libinput-debug-events.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2019-12-04 10:18:27 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2019-12-04 12:50:11 +1000
commit9696f3739376b71793e7eeff8427599cb594bdd2 (patch)
tree70456f207ecd46dc87fc02579244dbd5a422e718 /tools/libinput-debug-events.c
parentb8bbf424de6b09b737d097f1549f5cb158ee40a4 (diff)
downloadlibinput-9696f3739376b71793e7eeff8427599cb594bdd2.tar.gz
tools: debug-events: don't overrun the device array with too many arguments
Only the --device option was checked for argument count, not the rest so it's easy to overrun the array by specifying too many devices. Except: this was a theoretical bug only, more than 64 arguments trigger an assertion in the argv processing in tools/shared.c anyway. Let's drop the debug-events limit to 60 devices so we can at least have a test for this. Found by coverity Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools/libinput-debug-events.c')
-rw-r--r--tools/libinput-debug-events.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/libinput-debug-events.c b/tools/libinput-debug-events.c
index bdabb544..079aa7c8 100644
--- a/tools/libinput-debug-events.c
+++ b/tools/libinput-debug-events.c
@@ -935,7 +935,7 @@ main(int argc, char **argv)
{
struct libinput *li;
enum tools_backend backend = BACKEND_NONE;
- char *seat_or_devices[64] = {NULL};
+ char *seat_or_devices[60] = {NULL};
size_t ndevices = 0;
bool grab = false;
bool verbose = false;
@@ -1028,6 +1028,10 @@ main(int argc, char **argv)
}
backend = BACKEND_DEVICE;
do {
+ if (ndevices >= ARRAY_LENGTH(seat_or_devices)) {
+ usage();
+ return EXIT_INVALID_USAGE;
+ }
seat_or_devices[ndevices++] = safe_strdup(argv[optind]);
} while(++optind < argc);
} else if (backend == BACKEND_NONE) {