From: Ophir Munk Date: Sun, 18 Oct 2020 14:21:47 +0000 (+0000) Subject: app/regex: fix crash in options parsing X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=06ca0e4baa6eb8c5e3251199437c42672a037967;p=dpdk.git app/regex: fix crash in options parsing getopt_long() parses command-line arguments. One of its arguments 'longopts' is a pointer to the first element of an array of struct option. The last element of the array has to be filled with zeros to mark the end of options. For example: struct option longopts[] = { { "help", 0, 0, ARG_HELP}, .... /* End of options */ { 0, 0, 0, 0 } }; This commit adds the last element. Prior to this commit getopt_long() continued parsing beyond the longopts[] array which occasionally caused segmentation faults. Fixes: de06137cb295 ("app/regex: add RegEx test application") Cc: stable@dpdk.org Signed-off-by: Ophir Munk Acked-by: Ori Kam Acked-by: Lukasz Wojciechowski --- diff --git a/app/test-regex/main.c b/app/test-regex/main.c index 0d35f45834..e6080b44bc 100644 --- a/app/test-regex/main.c +++ b/app/test-regex/main.c @@ -66,7 +66,9 @@ args_parse(int argc, char **argv, char *rules_file, char *data_file, /* Perf test only */ { "perf", 0, 0, ARG_PERF_MODE}, /* Number of iterations to run with perf test */ - { "nb_iter", 1, 0, ARG_NUM_OF_ITERATIONS} + { "nb_iter", 1, 0, ARG_NUM_OF_ITERATIONS}, + /* End of options */ + { 0, 0, 0, 0 } }; argvopt = argv;