Skip to content

Commit

Permalink
tools: don't assert on 64+ commandline arguments, just return
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
whot committed Jul 22, 2020
1 parent 16ec180 commit e4343c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tools/test-tool-option-parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
5 changes: 4 additions & 1 deletion tools/tools-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down

0 comments on commit e4343c2

Please sign in to comment.