]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
TLS: check for sock->recv_cb when handling received data
authorArtem Boldariev <artem@boldariev.com>
Tue, 22 Nov 2022 13:11:57 +0000 (15:11 +0200)
committerArtem Boldariev <artem@boldariev.com>
Fri, 2 Dec 2022 11:20:37 +0000 (13:20 +0200)
This commit adds a check if 'sock->recv_cb' might have been nullified
during the call to 'sock->recv_cb'. That could happen, e.g. by an
indirect call to 'isc_nmhandle_close()' from within the callback when
wrapping up.

In this case, let's close the TLS connection.

lib/isc/netmgr/tlsstream.c

index 1ac83f4c7ee61ce4d4addf98fd7a73a3813cf395..61fc304a8afbb468aae1887257dd4cc0cccd921e 100644 (file)
@@ -547,6 +547,20 @@ tls_do_bio(isc_nmsocket_t *sock, isc_region_t *received_data,
                                if (sock->statichandle == NULL) {
                                        finish = true;
                                        break;
+                               } else if (sock->recv_cb == NULL) {
+                                       /*
+                                        * The 'sock->recv_cb' might have been
+                                        * nullified during the call to
+                                        * 'sock->recv_cb'. That could happen,
+                                        * e.g. by an indirect call to
+                                        * 'isc_nmhandle_close()' from within
+                                        * the callback when wrapping up.
+                                        *
+                                        * In this case, let's close the TLS
+                                        * connection.
+                                        */
+                                       finish = true;
+                                       break;
                                } else if (!sock->reading) {
                                        /*
                                         * Reading has been paused from withing