summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-02-17 21:59:23 +0100
committerattilamolnar <attilamolnar@hush.com>2013-02-17 21:59:23 +0100
commitd8e92ecc5e1cfced8bc5ed429dfb2eab5d8ae8ae (patch)
treed854e485c80fad52ecc9067f72ba4d987e7db651
parent83e36af589b433b00482e3c6b617165606e1ccbd (diff)
m_ssl_gnutls Fix null pointer dereference in case gnutls_xxx_get_name() returns NULL
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index b2b65eb69..38b3700b5 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -195,6 +195,12 @@ class ModuleSSLGnuTLS : public Module
GenericCap capHandler;
ServiceProvider iohook;
+
+ inline static const char* UnknownIfNULL(const char* str)
+ {
+ return str ? str : "UNKNOWN";
+ }
+
public:
ModuleSSLGnuTLS()
@@ -701,10 +707,12 @@ class ModuleSSLGnuTLS : public Module
{
if (sessions[user->eh.GetFd()].sess)
{
+ const gnutls_session_t& sess = sessions[user->eh.GetFd()].sess;
+ std::string cipher = UnknownIfNULL(gnutls_kx_get_name(gnutls_kx_get(sess)));
+ cipher.append("-").append(UnknownIfNULL(gnutls_cipher_get_name(gnutls_cipher_get(sess)))).append("-");
+ cipher.append(UnknownIfNULL(gnutls_mac_get_name(gnutls_mac_get(sess))));
+
ssl_cert* cert = sessions[user->eh.GetFd()].cert;
- std::string cipher = gnutls_kx_get_name(gnutls_kx_get(sessions[user->eh.GetFd()].sess));
- cipher.append("-").append(gnutls_cipher_get_name(gnutls_cipher_get(sessions[user->eh.GetFd()].sess))).append("-");
- cipher.append(gnutls_mac_get_name(gnutls_mac_get(sessions[user->eh.GetFd()].sess)));
if (cert->fingerprint.empty())
user->WriteServ("NOTICE %s :*** You are connected using SSL cipher \"%s\"", user->nick.c_str(), cipher.c_str());
else