]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix crash in TLS caused by improper handling of shutdown messages
authorArtem Boldariev <artem@boldariev.com>
Wed, 12 May 2021 11:39:24 +0000 (14:39 +0300)
committerArtem Boldariev <artem@boldariev.com>
Thu, 13 May 2021 07:42:25 +0000 (10:42 +0300)
The problem was found when flamethrower was accidentally run in DoT
mode against DoH port.

lib/isc/netmgr/tlsstream.c

index ec339a738a10f8f17020c65a53bf585a7d917aaf..3c2a60c46c7344be1641308e906992f1614c9a46 100644 (file)
@@ -382,8 +382,9 @@ tls_do_bio(isc_nmsocket_t *sock, isc_region_t *received_data,
                                          send_data->uvbuf.base,
                                          send_data->uvbuf.len, &len);
                        if (rv != 1 || len != send_data->uvbuf.len) {
-                               result = received_shutdown ? ISC_R_CANCELED
-                                                          : ISC_R_TLSERROR;
+                               result = received_shutdown || sent_shutdown
+                                                ? ISC_R_CANCELED
+                                                : ISC_R_TLSERROR;
                                send_data->cb.send(send_data->handle, result,
                                                   send_data->cbarg);
                                send_data = NULL;
@@ -396,9 +397,9 @@ tls_do_bio(isc_nmsocket_t *sock, isc_region_t *received_data,
                                 * connection and called isc_tls_send(). The
                                 * socket will be detached there, in
                                 * tls_senddone().*/
-                               if (sent_shutdown && received_shutdown) {
+                               if (sent_shutdown || received_shutdown) {
                                        return;
-                               } else if (!received_shutdown) {
+                               } else {
                                        isc__nmsocket_detach(&sock);
                                        return;
                                }