]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: server: always call ssl->destroy_srv when available
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 9 Mar 2023 13:28:00 +0000 (14:28 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Apr 2023 06:58:16 +0000 (08:58 +0200)
commitb5ee8bebfc9f7cba6063b7e3424f96c0d7ed3d47
tree43cb10b201c98efa8dbc6d7e0eb278caea3bec78
parentcca33550749449f713b37fed20b8e45421a15490
MINOR: server: always call ssl->destroy_srv when available

In srv_drop(), we only call the ssl->destroy_srv() method on
specific conditions.

But this has two downsides:

First, destroy_srv() is reponsible for freeing data that may have been
allocated in prepare_srv(), but not exclusively: it also frees
ssl-related parameters allocated when parsing a server entry, such as
ca-file for instance.

So this is quite error-prone, we could easily miss a condition where
some data needs to be deallocated using destroy_srv() even if
prepare_srv() was not used (since prepare_srv() is also conditional),
thus resulting in memory leaks.

Moreover, depending on srv->proxy to guard the check is probably not
a good idea here, since srv_drop() could be called in late de-init paths
in which related proxy could be freed already. srv_drop() should only
take care of freeing local server data without external logic.

Thankfully, destroy_srv() function performs the necessary checks to
ensure that a systematic call to the function won't result in invalid
reads or double frees.

No backport needed.
src/server.c