From 22862b8f1a6f42be6640224ee3f704f532604723 Mon Sep 17 00:00:00 2001 From: peavey Date: Sat, 4 Jul 2009 21:31:40 +0000 Subject: Fix possible segfault on giving an unknown cmdline argument. index holds the ref to the longopts array if found else it is NULL. optind however holds the next argv to be processed thus optind-1 is the correct index value to use. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11439 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index ca89e0ef3..6ff5bfb30 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -464,7 +464,7 @@ InspIRCd::InspIRCd(int argc, char** argv) /* Unknown parameter */ default: /* Fall through to handle other weird values too */ - printf("Unknown parameter '%s'\n", argv[index]); + printf("Unknown parameter '%s'\n", argv[optind-1]); printf("Usage: %s [--nofork] [--nolog] [--debug] [--logfile ]\n\ [--runasroot] [--version] [--config ] [--testsuite]\n", argv[0]); Exit(EXIT_STATUS_ARGV); -- cgit v1.2.3