From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7F0ABA04B0; Sun, 18 Oct 2020 16:21:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1DB6E29C6; Sun, 18 Oct 2020 16:21:56 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id C5E4F29C6 for ; Sun, 18 Oct 2020 16:21:54 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from ophirmu@nvidia.com) with SMTP; 18 Oct 2020 17:21:49 +0300 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09IELnQA020396; Sun, 18 Oct 2020 17:21:49 +0300 From: Ophir Munk To: dev@dpdk.org, Raslan Darawsheh , Ori Kam Cc: Ophir Munk , stable@dpdk.org Date: Sun, 18 Oct 2020 14:21:47 +0000 Message-Id: <20201018142147.11456-1-ophirmu@nvidia.com> X-Mailer: git-send-email 2.8.4 Subject: [dpdk-dev] [PATCH v1] app/regex: fix segfault in getopt_long call X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- app/test-regex/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/test-regex/main.c b/app/test-regex/main.c index 0d35f45..e6080b4 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; -- 2.8.4