]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: ssl: leak of ckch_inst_link in ckch_inst_free() v2
authorWilliam Lallemand <wlallemand@haproxy.org>
Wed, 31 Aug 2022 12:26:49 +0000 (14:26 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Wed, 31 Aug 2022 13:24:01 +0000 (15:24 +0200)
commite0fa91ffe16a91d758154ff900d16b16b368e81b
tree09feff52b3d357e1570a995b4b715c27d6422264
parentbccbad2654908140dec8d5dab368f6109cc7e559
BUG/MINOR: ssl: leak of ckch_inst_link in ckch_inst_free() v2

ckch_inst_free() unlink the ckch_inst_link structure but never free it.

It can't be fixed simply because cli_io_handler_commit_cafile_crlfile()
is using a cafile_entry list to iterate a list of ckch_inst entries
to free. So both cli_io_handler_commit_cafile_crlfile() and
ckch_inst_free() would modify the list at the same time.

In order to let the caller manipulate the ckch_inst_link,
ckch_inst_free() now checks if the element is still attached before
trying to detach and free it.

For this trick to work, the caller need to do a LIST_DEL_INIT() during
the iteration over the ckch_inst_link.

list_for_each_entry was also replace by a while (!LIST_ISEMPTY()) on the
head list in cli_io_handler_commit_cafile_crlfile() so the iteration
works correctly, because it could have been stuck on the first detached
element. list_for_each_entry_safe() is not enough to fix the issue since
multiple element could have been removed.

Must be backported as far as 2.5.
src/ssl_ckch.c