From b807e3fa975cf25e5e901b59643419a5a73a12fe Mon Sep 17 00:00:00 2001 From: Alexey Melnikov Date: Mon, 19 Jun 2017 13:01:54 +0100 Subject: Don't crash when SSL_new fails NULL pointer dereference was happening in OpenSSL code (inside SSL_set_bio) when SSL_new returned NULL due to lack of Isode HGE license. Change-Id: Iebd78be7eb6c7978de0bff225915dc393a516f08 diff --git a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp index cd6b6bc..0805917 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp @@ -121,6 +121,12 @@ void OpenSSLContext::ensureLibraryInitialized() { void OpenSSLContext::connect() { handle_ = SSL_new(context_); + if (handle_ == nullptr) { + state_ = Error; + onError(std::make_shared()); + return; + } + // Ownership of BIOs is ransferred readBIO_ = BIO_new(BIO_s_mem()); writeBIO_ = BIO_new(BIO_s_mem()); -- cgit v0.10.2-6-g49f6