From 4a01be0d15f2c051a101d4b832261efe0f8b90c5 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 6 Oct 2021 00:41:56 +0100 Subject: Fix showing the address of a custom title instead of the title. --- src/modules/m_customtitle.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp index a51030602..36a974301 100644 --- a/src/modules/m_customtitle.cpp +++ b/src/modules/m_customtitle.cpp @@ -154,10 +154,8 @@ class ModuleCustomTitle : public Module, public Whois::LineEventListener { /* Insert our numeric before 312 */ const std::string* ctitle = cmd.ctitle.get(whois.GetTarget()); - if (ctitle) - { - whois.SendLine(RPL_WHOISSPECIAL, ctitle); - } + if (ctitle && !ctitle->empty()) + whois.SendLine(RPL_WHOISSPECIAL, *ctitle); } /* Don't block anything */ return MOD_RES_PASSTHRU; -- cgit v1.3.1-10-gc9f91 From 037964ba960e53ae5dbd5ff4984c17eeac61c2ef Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 13 Oct 2021 21:14:15 +0100 Subject: Use the OVERRIDE 005 token for showing the override user mode char. --- src/modules/m_override.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index 685c31fd2..f5408b8a2 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -111,7 +111,8 @@ class ModuleOverride : public Module void On005Numeric(std::map& tokens) CXX11_OVERRIDE { - tokens["OVERRIDE"]; + if (UmodeEnabled) + tokens["OVERRIDE"] = ConvToStr(ou.GetModeChar()); } bool CanOverride(User* source, const char* token) -- cgit v1.3.1-10-gc9f91 From 9caacf8e967781d6c1a7a849e4a09b75c7df2a88 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 14 Oct 2021 13:36:07 +0100 Subject: Make reading DNs more consistent across modules. - If the DN contains a new line character then replace it with a space instead of killing the entire DN in the ssl_gnutls and ssl_openssl modules. - Apply the same logic to ssl_mbedtls which previously did not handle spaces in DNs. --- src/modules/extra/m_ssl_gnutls.cpp | 21 +++++++++------------ src/modules/extra/m_ssl_mbedtls.cpp | 2 ++ src/modules/extra/m_ssl_openssl.cpp | 23 ++++++++++++----------- 3 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src/modules') diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 020f10482..1ccaddafc 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -839,21 +839,11 @@ class GnuTLSIOHook : public SSLIOHook } if (gnutls_x509_crt_get_dn(cert, buffer, &buffer_size) == 0) - { - // Make sure there are no chars in the string that we consider invalid. - certinfo->dn = buffer; - if (certinfo->dn.find_first_of("\r\n") != std::string::npos) - certinfo->dn.clear(); - } + ProcessDNString(buffer, buffer_size, certinfo->dn); buffer_size = sizeof(buffer); if (gnutls_x509_crt_get_issuer_dn(cert, buffer, &buffer_size) == 0) - { - // Make sure there are no chars in the string that we consider invalid. - certinfo->issuer = buffer; - if (certinfo->issuer.find_first_of("\r\n") != std::string::npos) - certinfo->issuer.clear(); - } + ProcessDNString(buffer, buffer_size, certinfo->issuer); buffer_size = sizeof(buffer); if ((ret = gnutls_x509_crt_get_fingerprint(cert, GetProfile().GetHash(), buffer, &buffer_size)) < 0) @@ -876,6 +866,13 @@ info_done_dealloc: gnutls_x509_crt_deinit(cert); } + static void ProcessDNString(const char* buffer, size_t buffer_size, std::string& out) + { + out.assign(buffer, buffer_size); + for (size_t pos = 0; ((pos = out.find_first_of("\r\n", pos)) != std::string::npos); ) + out[pos] = ' '; + } + // Returns 1 if application I/O should proceed, 0 if it must wait for the underlying protocol to progress, -1 on fatal error int PrepareIO(StreamSocket* sock) { diff --git a/src/modules/extra/m_ssl_mbedtls.cpp b/src/modules/extra/m_ssl_mbedtls.cpp index cf7c9020f..4c8c99f1a 100644 --- a/src/modules/extra/m_ssl_mbedtls.cpp +++ b/src/modules/extra/m_ssl_mbedtls.cpp @@ -649,6 +649,8 @@ class mbedTLSIOHook : public SSLIOHook return; out.assign(buf, ret); + for (size_t pos = 0; ((pos = out.find_first_of("\r\n", pos)) != std::string::npos); ) + out[pos] = ' '; } static int Pull(void* userptr, unsigned char* buffer, size_t size) diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index dda3195af..57af1316d 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -662,17 +662,8 @@ class OpenSSLIOHook : public SSLIOHook certinfo->trusted = false; } - char buf[512]; - X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf)); - certinfo->dn = buf; - // Make sure there are no chars in the string that we consider invalid - if (certinfo->dn.find_first_of("\r\n") != std::string::npos) - certinfo->dn.clear(); - - X509_NAME_oneline(X509_get_issuer_name(cert), buf, sizeof(buf)); - certinfo->issuer = buf; - if (certinfo->issuer.find_first_of("\r\n") != std::string::npos) - certinfo->issuer.clear(); + GetDNString(X509_get_subject_name(cert), certinfo->dn); + GetDNString(X509_get_issuer_name(cert), certinfo->issuer); if (!X509_digest(cert, GetProfile().GetDigest(), md, &n)) { @@ -691,6 +682,16 @@ class OpenSSLIOHook : public SSLIOHook X509_free(cert); } + static void GetDNString(const X509_NAME* x509name, std::string& out) + { + char buf[512]; + X509_NAME_oneline(x509name, buf, sizeof(buf)); + + out.assign(buf); + for (size_t pos = 0; ((pos = out.find_first_of("\r\n", pos)) != std::string::npos); ) + out[pos] = ' '; + } + void SSLInfoCallback(int where, int rc) { if ((where & SSL_CB_HANDSHAKE_START) && (status == STATUS_OPEN)) -- cgit v1.3.1-10-gc9f91