BUG/MEDIUM: server: srv_set_addr_desc() crashes when a server has no address
authorThayne McCombs <thayne@lucidchart.com>
Wed, 6 Jan 2021 06:10:09 +0000 (23:10 -0700)
committerWilly Tarreau <w@1wt.eu>
Wed, 6 Jan 2021 08:19:15 +0000 (09:19 +0100)
commit24da7e1aa6dba2dd97ec02245d80c619f5114abe
treeac390bbbe5dfd9d693e9dd4637b952d41d91d50e
parent1ab76dd956042019aabbfc2a04dc6a3101ce1a02
BUG/MEDIUM: server: srv_set_addr_desc() crashes when a server has no address

GitHub Issue #1026 reported a crash during configuration check for the
following example config:

    backend 0
    server 0 0
    server 0 0

HAProxy crashed in srv_set_addr_desc() due to a NULL pointer dereference
caused by `sa2str` returning NULL for an `AF_UNSPEC` address (`0`).

Check to make sure the address key is non-null before using it for
comparison or inserting it into the tree.

The crash was introduced in commit 92149f9a8 ("MEDIUM: stick-tables: Add
srvkey option to stick-table") which not in any released version so no
backport is needed.

Cc: Tim Duesterhus <tim@bastelstu.be>
src/server.c