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>
{
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;
}
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) {
self.run_command_success(['--device', '/dev/input/event0', '/dev/input/event0'])
self.run_command_success(['/dev/input/event0', '/dev/input/event1'])
+ def test_too_many_devices(self):
+ # Too many arguments just bails with the usage message
+ rc, stdout, stderr = self.run_command(['/dev/input/event0'] * 61)
+ self.assertEqual(rc, 2, msg=(stdout, stderr))
+
class TestDebugGUI(TestToolWithOptions, TestLibinputTool):
subtool = 'debug-gui'