From: Christopher Faulet Date: Tue, 7 Dec 2021 17:49:44 +0000 (+0100) Subject: BUG/MINOR: cli/server: Don't crash when a server is added with a custom id X-Git-Tag: v2.6-dev1~302 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=70f8948364524b83f4763f02ceea884019451e06;p=thirdparty%2Fhaproxy.git BUG/MINOR: cli/server: Don't crash when a server is added with a custom id When a server is dynamically added via the CLI with a custom id, the key used to insert it in the backend's tree of used names is not initialized. The server id must be used but it is only used when no custom id is provided. Thus, with a custom id, HAProxy crashes. Now, the server id is always used to init this key, to be able to insert the server in the corresponding tree. This patch should fix the issue #1481. It must be backported as far as 2.4. --- diff --git a/src/server.c b/src/server.c index 47bd38bc06..4f75dff5a1 100644 --- a/src/server.c +++ b/src/server.c @@ -4829,8 +4829,8 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct } srv->conf.id.key = srv->puid = next_id; - srv->conf.name.key = srv->id; } + srv->conf.name.key = srv->id; /* insert the server in the backend trees */ eb32_insert(&be->conf.used_server_id, &srv->conf.id);