From: W.C.A. Wijngaards Date: Tue, 24 Nov 2020 15:58:51 +0000 (+0100) Subject: - Fix crash when TLS connection is closed prematurely, when X-Git-Tag: release-1.13.0rc2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=978d3840dc6a28d634b1a184a62645663b679175;p=thirdparty%2Funbound.git - Fix crash when TLS connection is closed prematurely, when reuse tree comparison is not properly identical to insertion. --- diff --git a/doc/Changelog b/doc/Changelog index 9c609408e..a07b4a373 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -6,6 +6,8 @@ - iana portlist updated. - Fix one port unit test for udp-connect. - tag for the 1.13.0rc1 release. + - Fix crash when TLS connection is closed prematurely, when + reuse tree comparison is not properly identical to insertion. 23 November 2020: George - Merge PR #313 from Ralph Dolmans: Replace edns-client-tag with diff --git a/services/outside_network.c b/services/outside_network.c index 9391b05e2..a55cc1cd3 100644 --- a/services/outside_network.c +++ b/services/outside_network.c @@ -886,6 +886,14 @@ decommission_pending_tcp(struct outside_network* outnet, struct pending_tcp* pend) { verbose(VERB_CLIENT, "decommission_pending_tcp"); + pend->next_free = outnet->tcp_free; + outnet->tcp_free = pend; + if(pend->reuse.node.key) { + /* needs unlink from the reuse tree to get deleted */ + reuse_tcp_remove_tree_list(outnet, &pend->reuse); + } + /* free SSL structure after remove from outnet tcp reuse tree, + * because the c->ssl null or not is used for sorting in the tree */ if(pend->c->ssl) { #ifdef HAVE_SSL SSL_shutdown(pend->c->ssl); @@ -894,12 +902,6 @@ decommission_pending_tcp(struct outside_network* outnet, #endif } comm_point_close(pend->c); - pend->next_free = outnet->tcp_free; - outnet->tcp_free = pend; - if(pend->reuse.node.key) { - /* needs unlink from the reuse tree to get deleted */ - reuse_tcp_remove_tree_list(outnet, &pend->reuse); - } /* unlink the query and writewait list, it is part of the tree * nodes and is deleted */ pend->query = NULL;