From 4c86c370bb1e4b13f28328cb4905a81dffbee792 Mon Sep 17 00:00:00 2001 From: Elias Ohm Date: Thu, 9 May 2019 09:30:12 +0200 Subject: [PATCH] fixup errbuf length in the other files and avoid using the static buffer in one place (for thread safety and code consistency reasons) --- lib/base/tlsstream.cpp | 5 +++-- lib/remote/pkiutility.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/base/tlsstream.cpp b/lib/base/tlsstream.cpp index 5f6fe33cf..210d88002 100644 --- a/lib/base/tlsstream.cpp +++ b/lib/base/tlsstream.cpp @@ -61,7 +61,7 @@ TlsStream::TlsStream(const Socket::Ptr& socket, const String& hostname, Connecti m_CurrentAction(TlsActionNone), m_Retry(false), m_Shutdown(false) { std::ostringstream msgbuf; - char errbuf[120]; + char errbuf[256]; m_SSL = std::shared_ptr(SSL_new(sslContext), SSL_free); @@ -272,8 +272,9 @@ void TlsStream::OnEvent(int revents) m_ErrorOccurred = true; if (m_ErrorCode != 0) { + char errbuf[256]; Log(LogWarning, "TlsStream") - << "OpenSSL error: " << ERR_error_string(m_ErrorCode, nullptr); + << "OpenSSL error: " << ERR_error_string(m_ErrorCode, errbuf); } else { Log(LogWarning, "TlsStream", "TLS stream was disconnected."); } diff --git a/lib/remote/pkiutility.cpp b/lib/remote/pkiutility.cpp index c08989dd8..350b99361 100644 --- a/lib/remote/pkiutility.cpp +++ b/lib/remote/pkiutility.cpp @@ -53,7 +53,7 @@ int PkiUtility::NewCert(const String& cn, const String& keyfile, const String& c int PkiUtility::SignCsr(const String& csrfile, const String& certfile) { - char errbuf[120]; + char errbuf[256]; InitializeOpenSSL();