]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: mworker: fix the copy of options in copy_argv()
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 4 Jun 2020 15:40:23 +0000 (17:40 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Fri, 5 Jun 2020 12:30:34 +0000 (14:30 +0200)
commitdf6c5a8ffad7ec28ff6987dc6b1e26d68eb89c5e
treeb99c8e1b43912b63223c61f098530dca3057d2c8
parentefde955bdb7b7479267cfcd823cce26bb3f5c4d3
BUG/MEDIUM: mworker: fix the copy of options in copy_argv()

The copy_argv() function, which is used to copy and remove some of the
arguments of the command line in order to re-exec() the master process,
is poorly implemented.

The function tries to remove the -x and the -sf/-st options but without
taking into account that some of the options could take a parameter
starting with a dash.

In issue #644, haproxy starts with "-L -xfoo" which is perfectly
correct. However, the re-exec is done without "-xfoo" because the master
tries to remove the "-x" option. Indeed, the copy_argv() function does
not know how much arguments an option can have, and just assume that
everything starting with a dash is an option. So haproxy is exec() with
"-L" but without a parameter, which is wrong and leads to the exit of
the master, with usage().

To fix this issue, copy_argv() must know how much parameters an option
takes, and copy or skip the parameters correctly.

This fix is a first step but it should evolve to a cleaner way of
declaring the options to avoid deduplication of the parsing code, so we
avoid new bugs.

Should be backported with care as far as 1.8, by removing the options
that does not exists in the previous versions.
src/haproxy.c