]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: sink/log: properly deinit srv in sink_new_from_logsrv()
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 11 Jul 2023 07:31:06 +0000 (09:31 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 11 Jul 2023 08:26:09 +0000 (10:26 +0200)
commitc38cf3cf98d30d6d069c36d3d475511d892201b9
tree41f101169d1e90aa8805edde488260a11d9b5648
parentb58bd9794f146ee8801415bbf7958dcc95fc5643
BUG/MINOR: sink/log: properly deinit srv in sink_new_from_logsrv()

When errors are encountered in sink_new_from_logsrv() function,
incompetely allocated ressources are freed to prevent memory leaks.

For instance: logsrv implicit server is manually cleaned up on error prior
to returning from the function.

However, since 198e92a8e5 ("MINOR: server: add a global list of all known
servers") every server created using new_server() is registered to the
global list, but unfortunately the manual srv cleanup in
sink_new_from_logsrv() doesn't remove the srv from the global list, so the
freed server will still be referenced there, which can result in invalid
reads later.

Moreover, server API has evolved since, and now the srv_drop() function is
available for that purpose, so let's use it, but make sure that srv is
freed before the proxy because on older versions srv_drop() expects the
srv to be linked to a valid proxy pointer.

This must be backported up to 2.4.

[For 2.4 version, free_server() must be used instead of srv_drop()]
src/sink.c