tools: don't assert on 64+ commandline arguments, just return Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
diff --git a/tools/test-tool-option-parsing.py b/tools/test-tool-option-parsing.py
index ad3a599..27af46e 100755
--- a/tools/test-tool-option-parsing.py
+++ b/tools/test-tool-option-parsing.py
@@ -171,6 +171,10 @@ def test_xkbcli_version(xkbcli):
assert stderr == ''
+def test_xkbcli_too_many_args(xkbcli):
+ xkbcli.run_command_invalid(['a'] * 64)
+
+
@pytest.mark.parametrize('args', [['--verbose'],
['--rmlvo'],
['--kccgst'],
diff --git a/tools/tools-common.c b/tools/tools-common.c
index 0b42892..f7539fe 100644
--- a/tools/tools-common.c
+++ b/tools/tools-common.c
@@ -229,7 +229,10 @@ tools_exec_command(const char *prefix, int real_argc, char **real_argv)
char executable[128];
const char *command;
- assert((size_t)real_argc < ARRAY_SIZE(argv));
+ if (((size_t)real_argc >= ARRAY_SIZE(argv))) {
+ fprintf(stderr, "Too many arguments\n");
+ return EXIT_INVALID_USAGE;
+ }
command = real_argv[0];