]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix crash when TLS connection is closed prematurely, when
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 24 Nov 2020 15:58:51 +0000 (16:58 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 24 Nov 2020 15:58:51 +0000 (16:58 +0100)
  reuse tree comparison is not properly identical to insertion.

doc/Changelog
services/outside_network.c

index 9c609408e7c3326390cf8ba6a48f69441e9b0abe..a07b4a37378a7df6e424053d7f31d1d22aa0e0f8 100644 (file)
@@ -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
index 9391b05e2919bfaca9b1cc10acb52c146dd222f2..a55cc1cd3cd57791d667e6feb9d20b1ce709c60c 100644 (file)
@@ -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;