From b49594ea3e847092f93de2443eef36d700ece79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Mon, 22 Nov 2021 12:15:38 +0100 Subject: [PATCH 1/2] Catch all botan exception when sending data, not just TLS On invalid ASN1 file or things that are not specific to TLS only, botan throws other exceptions, and we need to catch those as well. fix #3460 --- src/network/tcp_socket_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/tcp_socket_handler.cpp b/src/network/tcp_socket_handler.cpp index ae23b3c..f5e0d68 100644 --- a/src/network/tcp_socket_handler.cpp +++ b/src/network/tcp_socket_handler.cpp @@ -194,7 +194,7 @@ void TCPSocketHandler::send_data(std::string&& data) if (this->use_tls) try { this->tls_send(std::move(data)); - } catch (const Botan::TLS::TLS_Exception& e) { + } catch (const Botan::Exception& e) { this->on_connection_close("TLS error: "s + e.what()); this->close(); return ; From 18b6006e30c26a2fb6196e3b16420de74a654a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Mon, 22 Nov 2021 12:34:15 +0100 Subject: [PATCH 2/2] Follow-up of the previous on: also catch that on recv events fix #3460 --- src/network/tcp_socket_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/tcp_socket_handler.cpp b/src/network/tcp_socket_handler.cpp index f5e0d68..5e4ae30 100644 --- a/src/network/tcp_socket_handler.cpp +++ b/src/network/tcp_socket_handler.cpp @@ -261,7 +261,7 @@ void TCPSocketHandler::tls_recv() const bool was_active = this->tls->is_active(); try { this->tls->received_data(recv_buf, static_cast(size)); - } catch (const Botan::TLS::TLS_Exception& e) { + } catch (const Botan::Exception& e) { // May happen if the server sends malformed TLS data (buggy server, // or more probably we are just connected to a server that sends // plain-text)