From 45eff44e28a36be113a933ee27f16ff5e92775bb Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Mon, 19 Jun 2017 15:57:55 +0200 Subject: [PATCH] BUG/MEDIUM: fix segfault when no argument to -x option This patch fixes a segfault in the command line parser. When haproxy is launched with -x with no argument and -x is the latest option in argv it segfaults. Use usage() insteads of exit() on error. --- src/haproxy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/haproxy.c b/src/haproxy.c index d64058dab..2fd387f3e 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -1279,9 +1279,9 @@ static void init(int argc, char **argv) else if (*flag == 'q') arg_mode |= MODE_QUIET; else if (*flag == 'x') { - if (argv[1][0] == '-') { - Alert("Unix socket path expected with the -x flag\n"); - exit(1); + if (argc <= 1 || argv[1][0] == '-') { + Alert("Unix socket path expected with the -x flag\n\n"); + usage(progname); } old_unixsocket = argv[1]; argv++;