That one can really make you crazy if you are in this exact case :-)

-- 
William Lallemand
>From ce9920d284e55600ef324a322a3aed92dd2af02f Mon Sep 17 00:00:00 2001
From: William Lallemand <wlallem...@haproxy.com>
Date: Tue, 9 Jan 2018 23:12:27 +0100
Subject: [PATCH] BUG/MEDIUM: mworker: execvp failure depending on argv[0]

The copy_argv() function lacks a check on '-' to remove the -x, -sf and
-st parameters.

When reloading a master process with a path starting by /st, /sf, or
/x..  the copy_argv() function skipped argv[0] leading to an execvp()
without the binary.
---
 src/haproxy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/haproxy.c b/src/haproxy.c
index e98420e2..20b18f85 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1242,7 +1242,8 @@ static char **copy_argv(int argc, char **argv)
 
 	while (i < argc) {
 		/* -sf or -st or -x */
-		if ((argv[i][1] == 's' && (argv[i][2] == 'f' || argv[i][2] == 't')) || argv[i][1] == 'x' ) {
+		if (i > 0 && argv[i][0] == '-' &&
+		    ((argv[i][1] == 's' && (argv[i][2] == 'f' || argv[i][2] == 't')) || argv[i][1] == 'x' )) {
 			/* list of pids to finish ('f') or terminate ('t') or unix socket (-x) */
 			i++;
 			while (i < argc && argv[i][0] != '-') {
-- 
2.13.6

Reply via email to