Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

m_ssl_gnutls Fix null pointer dereference in case gnutls_xxx_get_name…

…() returns NULL
  • Loading branch information...
commit d8e92ecc5e1cfced8bc5ed429dfb2eab5d8ae8ae 1 parent 83e36af
@attilamolnar attilamolnar authored
Showing with 11 additions and 3 deletions.
  1. +11 −3 src/modules/extra/m_ssl_gnutls.cpp
View
14 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
Please sign in to comment.
Something went wrong with that request. Please try again.