From: Artem Boldariev Date: Wed, 12 May 2021 11:39:24 +0000 (+0300) Subject: Fix crash in TLS caused by improper handling of shutdown messages X-Git-Tag: v9.17.14~61^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6816a741ca5b1d0929f5eb7293b4ed1d2f417a07;p=thirdparty%2Fbind9.git Fix crash in TLS caused by improper handling of shutdown messages The problem was found when flamethrower was accidentally run in DoT mode against DoH port. --- diff --git a/lib/isc/netmgr/tlsstream.c b/lib/isc/netmgr/tlsstream.c index ec339a738a1..3c2a60c46c7 100644 --- a/lib/isc/netmgr/tlsstream.c +++ b/lib/isc/netmgr/tlsstream.c @@ -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; }