]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: server/lbprm: fix crash in _srv_set_inetaddr_port()
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 3 Apr 2024 09:41:57 +0000 (11:41 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Wed, 3 Apr 2024 09:58:03 +0000 (11:58 +0200)
commit837a26ab05350413a63354a8dafc17ac5efc38ef
tree1a5e98e9a180bae9df1c406f0fe80925a5f6894b
parent0e14bac7bdd5c3bae4402c8185a9a9bb49ebe8db
BUG/MEDIUM: server/lbprm: fix crash in _srv_set_inetaddr_port()

Since faa8c3e ("MEDIUM: lb-chash: Deterministic node hashes based on
server address") the following configuration will cause haproxy to crash:

  backend test1
       mode http
       balance hash int(1)
       server s1 haproxy.org:80

This is because lbprm.update_server_eweight() method is now systematically
called in _srv_set_inetaddr_port() upon srv addr/port change (and with the
above config it happens during startup after initial dns resolution).

However, depending on the chosen lbprm algo, update_server_eweight function
may not be set (it is not a mandatory method, some lb implementations don't
define it).

Thus, using 'balance hash' with map-based hashing or 'balance sticky' will
cause a crash due to a NULL de-reference in _srv_set_inetaddr_port(). To
fix the issue, we first check that the update_server_eweight() method is
set before using it.

No backport needed unless faa8c3e ("MEDIUM: lb-chash: Deterministic node
hashes based on server address") gets backported.
src/server.c