tools: don't assert on 64+ commandline arguments, just return

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
master
Peter Hutterer 2020-07-22 11:15:27 +10:00 committed by Ran Benita
parent d480f053d2
commit ba52e34dce
2 changed files with 8 additions and 1 deletions

View File

@ -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'],

View File

@ -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];