]> git.ipfire.org Git - thirdparty/haproxy.git/commit
CLEANUP: server: be sure never to compare src against a non-existing defsrv
authorWilly Tarreau <w@1wt.eu>
Thu, 10 Jul 2025 14:42:42 +0000 (16:42 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 15 Jul 2025 08:33:08 +0000 (10:33 +0200)
commit2414c5ce2f057bcfa10c7b76fa9444f648c37c2d
tree8e811635fc3ca49cd1a7002389c7742741e9da09
parent36f339d2feb567e437eff52347eb7e976d409ad0
CLEANUP: server: be sure never to compare src against a non-existing defsrv

The test in srv_ssl_settings_cpy() comparing src to the server's proxy's
default server does work but it's a subtle trap. Indeed, no check is made
on srv->proxy to be valid, and this only works because the compiler is
comparing pointer offsets. During the boot, it's common to have NULL here
in srv->proxy and of course in this case srv does not match that value
which is NULL plus epsilon. But when trying to turn defsrv to a dynamic
pointer instead, then the compiler is forced to dereference this NULL
srv->proxy and dies during init.

Let's always add the null check for srv->proxy before the test to avoid
this situation.

No backport is needed since the problem cannot happen yet.
src/server.c