patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH v1] app/regex: fix segfault in getopt_long call
@ 2020-10-18 14:21 Ophir Munk
  2020-10-19  7:46 ` Ori Kam
  0 siblings, 1 reply; 6+ messages in thread
From: Ophir Munk @ 2020-10-18 14:21 UTC (permalink / raw)
  To: dev, Raslan Darawsheh, Ori Kam; +Cc: Ophir Munk, stable

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 <ophirmu@nvidia.com>
---
 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-10-19 22:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-18 14:21 [dpdk-stable] [PATCH v1] app/regex: fix segfault in getopt_long call Ophir Munk
2020-10-19  7:46 ` Ori Kam
2020-10-19  8:13   ` [dpdk-stable] [dpdk-dev] " Lukasz Wojciechowski
2020-10-19  8:39     ` Ophir Munk
2020-10-19 22:05       ` Thomas Monjalon
2020-10-19 22:06     ` Thomas Monjalon

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git