mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-03-21 16:50:42 +01:00
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>
This commit is contained in:
parent
b8bbf424de
commit
9696f37393
2 changed files with 10 additions and 1 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -212,6 +212,11 @@ class TestDebugEvents(TestToolWithOptions, TestLibinputTool):
|
|||
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'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue