]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: fix segfault when no argument to -x option
authorWilliam Lallemand <wlallemand@haproxy.com>
Mon, 19 Jun 2017 13:57:55 +0000 (15:57 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 20 Jun 2017 12:43:28 +0000 (14:43 +0200)
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

index d64058dab51f6d58f3b1ff00b69dd1d2a30b4525..2fd387f3ef97bc5f611084aace2a43bf1b79ec8e 100644 (file)
@@ -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++;