BUG/MEDIUM: server: segv when adding server with hostname from CLI
When calling 'add server' with a hostname from the cli (runtime), str2sa_range() does not resolve hostname because it is purposely called without PA_O_RESOLVE flag. This leads to 'srv->addr_node.key' being NULL. According to Willy it is fine behavior, as long as we handle it properly, and is already handled like this in srv_set_addr_desc(). This patch fixes GH #1865 by adding an extra check before inserting 'srv->addr_node' into 'be->used_server_addr'. Insertion and removal will be skipped if 'addr_node.key' is NULL. It must be backported to 2.6 and 2.5 only. (cherry picked from commit 8d0ff284064e7a47ae46897e0ce9b08abe539315) Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
This commit is contained in:
parent
2ff9519605
commit
d87047115f
@ -4839,7 +4839,9 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct
|
||||
/* insert the server in the backend trees */
|
||||
eb32_insert(&be->conf.used_server_id, &srv->conf.id);
|
||||
ebis_insert(&be->conf.used_server_name, &srv->conf.name);
|
||||
ebis_insert(&be->used_server_addr, &srv->addr_node);
|
||||
/* addr_node.key could be NULL if FQDN resolution is postponed (ie: add server from cli) */
|
||||
if (srv->addr_node.key)
|
||||
ebis_insert(&be->used_server_addr, &srv->addr_node);
|
||||
|
||||
thread_release();
|
||||
|
||||
@ -5003,7 +5005,8 @@ static int cli_parse_delete_server(char **args, char *payload, struct appctx *ap
|
||||
/* remove srv from addr_node tree */
|
||||
eb32_delete(&srv->conf.id);
|
||||
ebpt_delete(&srv->conf.name);
|
||||
ebpt_delete(&srv->addr_node);
|
||||
if (srv->addr_node.key)
|
||||
ebpt_delete(&srv->addr_node);
|
||||
|
||||
/* remove srv from idle_node tree for idle conn cleanup */
|
||||
eb32_delete(&srv->idle_node);
|
||||
|
Loading…
x
Reference in New Issue
Block a user