From e2f1a61fc67500c4c101ff8a3f7847914298375e Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 18 Feb 2016 08:45:22 -0500 Subject: Fix dccallow to work with files with spaces in their names --- src/modules/m_dccallow.cpp | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 043486283..05fff8937 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -340,29 +340,43 @@ class ModuleDCCAllow : public Module return MOD_RES_PASSTHRU; } - // tokenize - std::stringstream ss(text); - std::string buf; - std::vector tokens; - - while (ss >> buf) - tokens.push_back(buf); - - if (tokens.size() < 2) + std::string buf = text.substr(5); + size_t s = buf.find(' '); + if (s == std::string::npos) return MOD_RES_PASSTHRU; - irc::string type = tokens[1].c_str(); + irc::string type = assign(buf.substr(0, s)); ConfigTag* conftag = ServerInstance->Config->ConfValue("dccallow"); bool blockchat = conftag->getBool("blockchat"); if (type == "SEND") { - if (tokens.size() < 3) + size_t first; + + buf = buf.substr(s + 1); + + if (!buf.empty() && buf[0] == '"') + { + s = buf.find('"', 1); + + if (s == std::string::npos || s <= 1) + return MOD_RES_PASSTHRU; + + --s; + first = 1; + } + else + { + s = buf.find(' '); + first = 0; + } + + if (s == std::string::npos) return MOD_RES_PASSTHRU; std::string defaultaction = conftag->getString("action"); - std::string filename = tokens[2]; + std::string filename = buf.substr(first, s); bool found = false; for (unsigned int i = 0; i < bfl.size(); i++) -- cgit v1.2.3 From b111d5098fe1ee306d2718c82c72f969db9d183d Mon Sep 17 00:00:00 2001 From: Guillaume Delacour Date: Sun, 28 Feb 2016 10:47:34 +0100 Subject: Minor spelling errors in m_spanningtree.so --- src/modules/m_spanningtree/fjoin.cpp | 2 +- src/modules/m_spanningtree/postcommand.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index 47b394522..4ec6e1dbb 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -201,7 +201,7 @@ CmdResult CommandFJoin::Handle(const std::vector& params, User *src } else { - ServerInstance->Logs->Log("m_spanningtree",SPARSE, "Ignored nonexistant user %s in fjoin to %s (probably quit?)", usr, channel.c_str()); + ServerInstance->Logs->Log("m_spanningtree",SPARSE, "Ignored nonexistent user %s in fjoin to %s (probably quit?)", usr, channel.c_str()); continue; } } diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp index 471bbfcb9..3f5d427e1 100644 --- a/src/modules/m_spanningtree/postcommand.cpp +++ b/src/modules/m_spanningtree/postcommand.cpp @@ -73,7 +73,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, const std::string & TreeServer* sdest = FindServer(routing.serverdest); if (!sdest) { - ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Trying to route ENCAP to nonexistant server %s", + ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Trying to route ENCAP to nonexistent server %s", routing.serverdest.c_str()); return; } -- cgit v1.2.3 From 4f8697d0ce29097583b417b676c73d31349b056f Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 29 Feb 2016 14:40:02 +0100 Subject: Remove embarrassing negative comments about some clients from the code --- src/commands/cmd_list.cpp | 1 - src/modules/m_securelist.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/commands/cmd_list.cpp b/src/commands/cmd_list.cpp index 2c420d1dd..8a99ce3e0 100644 --- a/src/commands/cmd_list.cpp +++ b/src/commands/cmd_list.cpp @@ -49,7 +49,6 @@ CmdResult CommandList::Handle (const std::vector& parameters, User user->WriteNumeric(321, "%s Channel :Users Name",user->nick.c_str()); - /* Work around mIRC suckyness. YOU SUCK, KHALED! */ if (parameters.size() == 1) { if (parameters[0][0] == '<') diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index 6013d1fd7..5d11d27f7 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -76,7 +76,7 @@ class ModuleSecureList : public Module /* Not exempt, BOOK EM DANNO! */ user->WriteServ("NOTICE %s :*** You cannot list within the first %lu seconds of connecting. Please try again later.",user->nick.c_str(), (unsigned long) WaitTime); - /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't + /* Some clients (e.g. mIRC, various java chat applets) muck up if they don't * receive these numerics whenever they send LIST, so give them an empty LIST to mull over. */ user->WriteNumeric(321, "%s Channel :Users Name",user->nick.c_str()); -- cgit v1.2.3 From 9b172942217bc6c25a9c0be82a1704ffe4f642bc Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Tue, 3 May 2016 18:47:15 +0100 Subject: Fix a minor warning in m_hideoper on some systems. --- src/modules/m_hideoper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index 9d50bd2e5..32999d9f0 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -94,7 +94,7 @@ class ModuleHideOper : public Module if (opercount) { active = true; - user->WriteNumeric(252, "%s %lu :operator(s) online", user->nick.c_str(), opercount); + user->WriteNumeric(252, "%s %lu :operator(s) online", user->nick.c_str(), static_cast(opercount)); active = false; } return MOD_RES_DENY; -- cgit v1.2.3 From 66f82ccf926aac39273bfc652c85c08080cc9a46 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 9 Jun 2016 15:12:35 +0200 Subject: Fix for GCC 6 rightfully optimizing out the NULL check of 'this' in ConfigTag::readString() Checking is only necessary in ModuleSSLInfo::OnPostConnect() as oper types are not encountered in the other cases but check anyway to be sure --- src/commands/cmd_oper.cpp | 2 +- src/modules/m_sslinfo.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/commands/cmd_oper.cpp b/src/commands/cmd_oper.cpp index 1a5e7e178..95f6b98df 100644 --- a/src/commands/cmd_oper.cpp +++ b/src/commands/cmd_oper.cpp @@ -69,7 +69,7 @@ CmdResult CommandOper::HandleLocal(const std::vector& parameters, L snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(),user->GetIPString()); OperIndex::iterator i = ServerInstance->Config->oper_blocks.find(parameters[0]); - if (i != ServerInstance->Config->oper_blocks.end()) + if ((i != ServerInstance->Config->oper_blocks.end()) && (i->second->oper_block)) { OperInfo* ifo = i->second; ConfigTag* tag = ifo->oper_block; diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index 2bfe0e1c4..083ac0f04 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -180,6 +180,9 @@ class ModuleSSLInfo : public Module if (i != ServerInstance->Config->oper_blocks.end()) { OperInfo* ifo = i->second; + if (!ifo->oper_block) + return MOD_RES_PASSTHRU; + ssl_cert* cert = cmd.CertExt.get(user); if (ifo->oper_block->getBool("sslonly") && !cert) @@ -220,6 +223,9 @@ class ModuleSSLInfo : public Module for(OperIndex::iterator i = ServerInstance->Config->oper_blocks.begin(); i != ServerInstance->Config->oper_blocks.end(); i++) { OperInfo* ifo = i->second; + if (!ifo->oper_block) + continue; + std::string fp = ifo->oper_block->getString("fingerprint"); if (fp == cert->fingerprint && ifo->oper_block->getBool("autologin")) user->Oper(ifo); -- cgit v1.2.3 From 86c3fde2fedfe9270eeaa1a93c0ea15d6fb9962d Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 21 Jun 2016 15:07:43 +0200 Subject: m_ssl_gnutls, m_ssl_openssl After a read schedule another read if data remains in the buffer of the SSL library --- src/modules/extra/m_ssl_gnutls.cpp | 3 +++ src/modules/extra/m_ssl_openssl.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 813a8ecfa..2f4acf3f0 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -703,6 +703,9 @@ class ModuleSSLGnuTLS : public Module if (ret > 0) { recvq.append(buffer, ret); + // Schedule a read if there is still data in the GnuTLS buffer + if (gnutls_record_check_pending(session->sess) > 0) + ServerInstance->SE->ChangeEventMask(user, FD_ADD_TRIAL_READ); return 1; } else if (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED) diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index b21091d3f..9e6472ac3 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -591,8 +591,15 @@ class ModuleSSLOpenSSL : public Module if (ret > 0) { recvq.append(buffer, ret); + + int mask = 0; + // Schedule a read if there is still data in the OpenSSL buffer + if (SSL_pending(session->sess) > 0) + mask |= FD_ADD_TRIAL_READ; if (session->data_to_write) - ServerInstance->SE->ChangeEventMask(user, FD_WANT_POLL_READ | FD_WANT_SINGLE_WRITE); + mask |= FD_WANT_POLL_READ | FD_WANT_SINGLE_WRITE; + if (mask != 0) + ServerInstance->SE->ChangeEventMask(user, mask); return 1; } else if (ret == 0) -- cgit v1.2.3 From 1f25ec70d144d85e28ec4d2769fefd8abb00cbca Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Fri, 22 Jul 2016 12:04:35 +0200 Subject: m_ssl_openssl Verify DH params being non-NULL before setting it on the context Fixes issue reported by @m4rkw on IRC --- src/modules/extra/m_ssl_openssl.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/modules') diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 9e6472ac3..aee7a5e34 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -405,12 +405,19 @@ class ModuleSSLOpenSSL : public Module #endif ERR_clear_error(); - if ((SSL_CTX_set_tmp_dh(ctx, ret) < 0) || (SSL_CTX_set_tmp_dh(clictx, ret) < 0)) + if (ret) { - ServerInstance->Logs->Log("m_ssl_openssl",DEFAULT, "m_ssl_openssl.so: Couldn't set DH parameters %s. SSL errors follow:", dhfile.c_str()); - ERR_print_errors_cb(error_callback, this); + if ((SSL_CTX_set_tmp_dh(ctx, ret) < 0) || (SSL_CTX_set_tmp_dh(clictx, ret) < 0)) + { + ServerInstance->Logs->Log("m_ssl_openssl", DEFAULT, "m_ssl_openssl.so: Couldn't set DH parameters %s. SSL errors follow:", dhfile.c_str()); + ERR_print_errors_cb(error_callback, this); + } + DH_free(ret); + } + else + { + ServerInstance->Logs->Log("m_ssl_openssl", DEFAULT, "m_ssl_openssl.so: Couldn't set DH parameters %s.", dhfile.c_str()); } - DH_free(ret); } #ifndef _WIN32 -- cgit v1.2.3 From 5f29158a5b7a892bde7dff26d87f94aacc8beadb Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 29 Jul 2016 13:09:43 -0400 Subject: Fix bursting channel bans --- src/modules/m_spanningtree/netburst.cpp | 25 ++++++++++++++----------- src/modules/m_spanningtree/treesocket.h | 2 ++ 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index d508c092d..3bce90eda 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -140,25 +140,28 @@ void TreeSocket::SendFJoins(Channel* c) buffer.append(list).append("\r\n"); } - int linesize = 1; + unsigned int linesize = 1; for (BanList::iterator b = c->bans.begin(); b != c->bans.end(); b++) { - int size = b->data.length() + 2; - int currsize = linesize + size; - if (currsize <= 350) - { - modes.append("b"); - params.append(" ").append(b->data); - linesize += size; - } - if ((modes.length() >= ServerInstance->Config->Limits.MaxModes) || (currsize > 350)) + unsigned int size = b->data.length() + 2; // "b" and " " + unsigned int nextsize = linesize + size; + + if ((modes.length() >= ServerInstance->Config->Limits.MaxModes) || (nextsize > FMODE_MAX_LENGTH)) { - /* Wrap at MAXMODES */ + /* Wrap */ buffer.append(":").append(ServerInstance->Config->GetSID()).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params).append("\r\n"); + modes.clear(); params.clear(); linesize = 1; } + + modes.push_back('b'); + + params.push_back(' '); + params.append(b->data); + + linesize += size; } /* Only send these if there are any */ diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h index abda28335..efcce5f7a 100644 --- a/src/modules/m_spanningtree/treesocket.h +++ b/src/modules/m_spanningtree/treesocket.h @@ -100,6 +100,8 @@ class TreeSocket : public BufferedSocket int proto_version; /* Remote protocol version */ bool ConnectionFailureShown; /* Set to true if a connection failure message was shown */ + static const unsigned int FMODE_MAX_LENGTH = 350; + /** Checks if the given servername and sid are both free */ bool CheckDuplicate(const std::string& servername, const std::string& sid); -- cgit v1.2.3 From 25cdcdc777c265124e55bf0fb94fdd856065f25b Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 5 Aug 2016 20:50:11 +0100 Subject: Fix challenge auth when using m_hash_gnutls instead of m_sha256. --- src/modules/m_spanningtree/capab.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp index 7b6435898..0ab815fef 100644 --- a/src/modules/m_spanningtree/capab.cpp +++ b/src/modules/m_spanningtree/capab.cpp @@ -27,6 +27,7 @@ #include "utils.h" #include "link.h" #include "main.h" +#include "../hash.h" std::string TreeSocket::MyModules(int filter) { @@ -134,7 +135,7 @@ void TreeSocket::SendCapabilities(int phase) std::string extra; /* Do we have sha256 available? If so, we send a challenge */ - if (Utils->ChallengeResponse && (ServerInstance->Modules->Find("m_sha256.so"))) + if (Utils->ChallengeResponse && (ServerInstance->Modules->FindDataService("hash/sha256"))) { SetOurChallenge(ServerInstance->GenRandomStr(20)); extra = " CHALLENGE=" + this->GetOurChallenge(); @@ -320,7 +321,7 @@ bool TreeSocket::Capab(const parameterlist ¶ms) /* Challenge response, store their challenge for our password */ std::map::iterator n = this->capab->CapKeys.find("CHALLENGE"); - if (Utils->ChallengeResponse && (n != this->capab->CapKeys.end()) && (ServerInstance->Modules->Find("m_sha256.so"))) + if (Utils->ChallengeResponse && (n != this->capab->CapKeys.end()) && (ServerInstance->Modules->FindDataService("hash/sha256"))) { /* Challenge-response is on now */ this->SetTheirChallenge(n->second); -- cgit v1.2.3 From e2dd99fa342b45364590ec72746e3118f1779538 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sat, 13 Aug 2016 18:11:57 +0200 Subject: Fix more incorrect std::string::operator[] usage --- src/commands/cmd_list.cpp | 2 +- src/commands/cmd_stats.cpp | 2 +- src/modules/m_sasl.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/modules') diff --git a/src/commands/cmd_list.cpp b/src/commands/cmd_list.cpp index 8a99ce3e0..eb28fb89c 100644 --- a/src/commands/cmd_list.cpp +++ b/src/commands/cmd_list.cpp @@ -49,7 +49,7 @@ CmdResult CommandList::Handle (const std::vector& parameters, User user->WriteNumeric(321, "%s Channel :Users Name",user->nick.c_str()); - if (parameters.size() == 1) + if ((parameters.size() == 1) && (!parameters[0].empty())) { if (parameters[0][0] == '<') { diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index d547635ed..aa5bf44cd 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -39,7 +39,7 @@ class CommandStats : public Command public: /** Constructor for stats. */ - CommandStats ( Module* parent) : Command(parent,"STATS",1,2) { syntax = " []"; } + CommandStats ( Module* parent) : Command(parent,"STATS",1,2) { allow_empty_last_param = false; syntax = " []"; } /** Handle command. * @param parameters The parameters to the comamnd * @param pcnt The number of parameters passed to teh command diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index 32c9afc79..9cb5592d1 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -147,7 +147,7 @@ class SaslAuthenticator SendSASL(params); - if (parameters[0][0] == '*') + if (parameters[0].c_str()[0] == '*') { this->Abort(); return false; -- cgit v1.2.3 From a8c7c85ecdb0449f35d5bb4037a61f461e9c4be0 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sat, 13 Aug 2016 18:23:12 +0200 Subject: m_censor Fix possible incorrect cast of dest --- src/modules/m_censor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index 50c8e22a7..65b965df2 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -101,7 +101,7 @@ class ModuleCensor : public Module { if (index->second.empty()) { - user->WriteNumeric(ERR_WORDFILTERED, "%s %s %s :Your message contained a censored word, and was blocked", user->nick.c_str(), ((Channel*)dest)->name.c_str(), index->first.c_str()); + user->WriteNumeric(ERR_WORDFILTERED, "%s %s %s :Your message contained a censored word, and was blocked", user->nick.c_str(), ((target_type == TYPE_CHANNEL) ? ((Channel*)dest)->name.c_str() : ((User*)dest)->nick.c_str()), index->first.c_str()); return MOD_RES_DENY; } -- cgit v1.2.3