From f3f762b77b5898ac0203d00bd64087e2a22e34be Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 10 May 2024 14:10:15 +0200 Subject: [PATCH] client/main: Fix array access Error: CPPCHECK_WARNING (CWE-788): [#def36] client/main.c:833: error[ctuArrayIndex]: Array index out of bounds; 'argv' buffer size is 0 and it is accessed at offset 1. 831| const char **opt; 832| 833|-> if (!strcmp(argv[1], "help")) { 834| for (opt = arg_table; opt && *opt; opt++) 835| bt_shell_printf("%s\n", *opt); --- client/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/main.c b/client/main.c index c8b0f7f1c..495dc98bb 100644 --- a/client/main.c +++ b/client/main.c @@ -830,6 +830,11 @@ static gboolean parse_argument(int argc, char *argv[], const char **arg_table, { const char **opt; + if (argc < 2) { + bt_shell_printf("Missing argument to %s\n", argv[0]); + return FALSE; + } + if (!strcmp(argv[1], "help")) { for (opt = arg_table; opt && *opt; opt++) bt_shell_printf("%s\n", *opt); -- 2.47.3