summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-04-07 13:40:51 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-04-07 13:40:51 +0200
commitf71e6bf9cb41811f18864f5d4eecb26e29d03f25 (patch)
tree88586e73f7ff864081b8831a88637680267b7201 /src
parentce78080782c261aed2c0314bc8c66babc1369be2 (diff)
parent493ff75f1f89a7ede2800eff0368740fbaf02aa4 (diff)
Merge insp20
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp3
-rw-r--r--src/cidr.cpp26
-rw-r--r--src/command_parse.cpp2
-rw-r--r--src/configreader.cpp3
-rw-r--r--src/coremods/core_channel/cmd_kick.cpp4
-rw-r--r--src/coremods/core_channel/cmd_names.cpp5
-rw-r--r--src/coremods/core_ison.cpp4
-rw-r--r--src/coremods/core_who.cpp2
-rw-r--r--src/inspircd.cpp2
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp10
-rw-r--r--src/modules/m_banredirect.cpp2
-rw-r--r--src/modules/m_globalload.cpp7
-rw-r--r--src/modules/m_httpd.cpp2
-rw-r--r--src/modules/m_operprefix.cpp3
-rw-r--r--src/modules/m_samode.cpp9
-rw-r--r--src/modules/m_saquit.cpp2
-rw-r--r--src/modules/m_spanningtree/idle.cpp2
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp5
-rw-r--r--src/modules/m_watch.cpp6
-rw-r--r--src/socket.cpp2
-rw-r--r--src/socketengines/socketengine_select.cpp4
21 files changed, 57 insertions, 48 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index c2060b90e..4555deb96 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -648,6 +648,7 @@ void Channel::UserList(User *user)
*/
bool has_user = this->HasUser(user);
+ const size_t maxlen = ServerInstance->Config->Limits.MaxLine - 10 - ServerInstance->Config->ServerName.size();
std::string prefixlist;
std::string nick;
for (UserMembIter i = userlist.begin(); i != userlist.end(); ++i)
@@ -675,7 +676,7 @@ void Channel::UserList(User *user)
if (nick.empty())
continue;
- if (list.size() + prefixlist.length() + nick.length() + 1 > 480)
+ if (list.size() + prefixlist.length() + nick.length() + 1 > maxlen)
{
/* list overflowed into multiple numerics */
user->WriteNumeric(RPL_NAMREPLY, list);
diff --git a/src/cidr.cpp b/src/cidr.cpp
index d6370b06a..875b95304 100644
--- a/src/cidr.cpp
+++ b/src/cidr.cpp
@@ -21,25 +21,7 @@
#include "inspircd.h"
-/* Used when comparing CIDR masks for the modulus bits left over.
- * A lot of ircd's seem to do this:
- * ((-1) << (8 - (mask % 8)))
- * But imho, it sucks in comparison to a nice neat lookup table.
- */
-const unsigned char inverted_bits[8] = { 0x00, /* 00000000 - 0 bits - never actually used */
- 0x80, /* 10000000 - 1 bits */
- 0xC0, /* 11000000 - 2 bits */
- 0xE0, /* 11100000 - 3 bits */
- 0xF0, /* 11110000 - 4 bits */
- 0xF8, /* 11111000 - 5 bits */
- 0xFC, /* 11111100 - 6 bits */
- 0xFE /* 11111110 - 7 bits */
-};
-
-
/* Match CIDR strings, e.g. 127.0.0.1 to 127.0.0.0/8 or 3ffe:1:5:6::8 to 3ffe:1::0/32
- * If you have a lot of hosts to match, youre probably better off building your mask once
- * and then using the lower level MatchCIDRBits directly.
*
* This will also attempt to match any leading usernames or nicknames on the mask, using
* match(), when match_with_username is true.
@@ -81,8 +63,14 @@ bool irc::sockets::MatchCIDR(const std::string &address, const std::string &cidr
cidr_copy.assign(cidr_mask);
}
- if (cidr_copy.find('/') == std::string::npos)
+ const std::string::size_type per_pos = cidr_copy.rfind('/');
+ if ((per_pos == std::string::npos) || (per_pos == cidr_copy.length()-1)
+ || (cidr_copy.find_first_not_of("0123456789", per_pos+1) != std::string::npos)
+ || (cidr_copy.find_first_not_of("0123456789abcdef.:") < per_pos))
+ {
+ // The CIDR mask is invalid
return false;
+ }
irc::sockets::sockaddrs addr;
irc::sockets::aptosa(address_copy, 0, addr);
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 7133b3f05..d89d7cbb5 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -281,7 +281,7 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd)
user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :This command has been disabled.", command.c_str());
}
- ServerInstance->SNO->WriteToSnoMask('t', "%s denied for %s (%s@%s)",
+ ServerInstance->SNO->WriteToSnoMask('a', "%s denied for %s (%s@%s)",
command.c_str(), user->nick.c_str(), user->ident.c_str(), user->host.c_str());
return;
}
diff --git a/src/configreader.cpp b/src/configreader.cpp
index baeffb015..cda5e03e0 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -586,7 +586,10 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
User* user = useruid.empty() ? NULL : ServerInstance->FindNick(useruid);
if (!valid)
+ {
ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "There were errors in your configuration file:");
+ Classes.clear();
+ }
while (errstr.good())
{
diff --git a/src/coremods/core_channel/cmd_kick.cpp b/src/coremods/core_channel/cmd_kick.cpp
index 260264faf..715f35d54 100644
--- a/src/coremods/core_channel/cmd_kick.cpp
+++ b/src/coremods/core_channel/cmd_kick.cpp
@@ -43,9 +43,9 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
else
u = ServerInstance->FindNick(parameters[1]);
- if (!u || !c)
+ if ((!u) || (!c) || (u->registered != REG_ALL))
{
- user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", u ? parameters[0].c_str() : parameters[1].c_str());
+ user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", c ? parameters[1].c_str() : parameters[0].c_str());
return CMD_FAILURE;
}
diff --git a/src/coremods/core_channel/cmd_names.cpp b/src/coremods/core_channel/cmd_names.cpp
index 81ada28bc..13d912376 100644
--- a/src/coremods/core_channel/cmd_names.cpp
+++ b/src/coremods/core_channel/cmd_names.cpp
@@ -46,11 +46,6 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User
c = ServerInstance->FindChan(parameters[0]);
if (c)
{
- if ((c->IsModeSet(secretmode)) && (!c->HasUser(user)))
- {
- user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", c->name.c_str());
- return CMD_FAILURE;
- }
c->UserList(user);
}
else
diff --git a/src/coremods/core_ison.cpp b/src/coremods/core_ison.cpp
index c7ead2a87..53d2e1c49 100644
--- a/src/coremods/core_ison.cpp
+++ b/src/coremods/core_ison.cpp
@@ -52,7 +52,7 @@ CmdResult CommandIson::Handle (const std::vector<std::string>& parameters, User
if (ison_already.find(u) != ison_already.end())
continue;
- if (u)
+ if ((u) && (u->registered == REG_ALL))
{
reply.append(u->nick).append(" ");
if (reply.length() > 450)
@@ -77,7 +77,7 @@ CmdResult CommandIson::Handle (const std::vector<std::string>& parameters, User
if (ison_already.find(u) != ison_already.end())
continue;
- if (u)
+ if ((u) && (u->registered == REG_ALL))
{
reply.append(u->nick).append(" ");
if (reply.length() > 450)
diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp
index 2c120e562..6f4bc088e 100644
--- a/src/coremods/core_who.cpp
+++ b/src/coremods/core_who.cpp
@@ -360,7 +360,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
{
if (!user->SharesChannelWith(oper))
{
- if (usingwildcards && (!oper->IsModeSet(invisiblemode)) && (!user->HasPrivPermission("users/auspex")))
+ if (usingwildcards && (oper->IsModeSet(invisiblemode)) && (!user->HasPrivPermission("users/auspex")))
continue;
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 5097960e8..24072868a 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -382,7 +382,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
/* Set the finished argument values */
Config->cmdline.nofork = (do_nofork != 0);
Config->cmdline.forcedebug = (do_debug != 0);
- Config->cmdline.writelog = (!do_nolog != 0);
+ Config->cmdline.writelog = !do_nolog;
if (do_debug)
{
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index ee024318b..7a8bdeeb0 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -109,6 +109,9 @@ namespace OpenSSL
{
SSL_CTX_set_mode(ctx, SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, OnVerify);
+
+ const unsigned char session_id[] = "inspircd";
+ SSL_CTX_set_session_id_context(ctx, session_id, sizeof(session_id) - 1);
}
~Context()
@@ -352,8 +355,11 @@ class OpenSSLIOHook : public SSLIOHook
certinfo->trusted = false;
}
- certinfo->dn = X509_NAME_oneline(X509_get_subject_name(cert),0,0);
- certinfo->issuer = X509_NAME_oneline(X509_get_issuer_name(cert),0,0);
+ char buf[512];
+ X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf));
+ certinfo->dn = buf;
+ X509_NAME_oneline(X509_get_issuer_name(cert), buf, sizeof(buf));
+ certinfo->issuer = buf;
if (!X509_digest(cert, profile->GetDigest(), md, &n))
{
diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp
index b0be8d665..1a123e580 100644
--- a/src/modules/m_banredirect.cpp
+++ b/src/modules/m_banredirect.cpp
@@ -316,7 +316,7 @@ class ModuleBanRedirect : public Module
else
{
user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s :Cannot join channel (You are banned)", chan->name.c_str());
- user->WriteNumeric(470, "%s %s :You are banned from this channel, so you are automatically transfered to the redirected channel.", chan->name.c_str(), redir->targetchan.c_str());
+ user->WriteNumeric(470, "%s %s :You are banned from this channel, so you are automatically transferred to the redirected channel.", chan->name.c_str(), redir->targetchan.c_str());
nofollow = true;
Channel::JoinUser(user, redir->targetchan);
nofollow = false;
diff --git a/src/modules/m_globalload.cpp b/src/modules/m_globalload.cpp
index b3c664cf1..8ee8472e6 100644
--- a/src/modules/m_globalload.cpp
+++ b/src/modules/m_globalload.cpp
@@ -153,7 +153,12 @@ class CommandGreloadmodule : public Command
{
Module* m = ServerInstance->Modules->Find(parameters[0]);
if (m)
- ServerInstance->Modules->Reload(m, new GReloadModuleWorker(user->nick, user->uuid, parameters[0]));
+ {
+ GReloadModuleWorker* worker = NULL;
+ if (m != creator)
+ worker = new GReloadModuleWorker(user->nick, user->uuid, parameters[0]);
+ ServerInstance->Modules->Reload(m, worker);
+ }
else
{
user->WriteNumeric(RPL_LOADEDMODULE, "%s :Could not find module by that name", parameters[0].c_str());
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp
index d0291b8cc..053f4b924 100644
--- a/src/modules/m_httpd.cpp
+++ b/src/modules/m_httpd.cpp
@@ -104,7 +104,7 @@ class HttpServerSocket : public BufferedSocket
case 300:
return "MULTIPLE CHOICES";
case 301:
- return "MOVED PERMENANTLY";
+ return "MOVED PERMANENTLY";
case 302:
return "FOUND";
case 303:
diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp
index 4fb4ae942..3bf4c8434 100644
--- a/src/modules/m_operprefix.cpp
+++ b/src/modules/m_operprefix.cpp
@@ -113,7 +113,8 @@ HideOperWatcher::HideOperWatcher(ModuleOperPrefixMode* parent)
void HideOperWatcher::AfterMode(User* source, User* dest, Channel* channel, const std::string& parameter, bool adding)
{
- if (IS_LOCAL(dest))
+ // If hideoper is being unset because the user is deopering, don't set +y
+ if (IS_LOCAL(dest) && dest->IsOper())
parentmod->SetOperPrefix(dest, !adding);
}
diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp
index 129ad3f7b..14f79aaf7 100644
--- a/src/modules/m_samode.cpp
+++ b/src/modules/m_samode.cpp
@@ -37,6 +37,15 @@ class CommandSamode : public Command
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
{
+ if (parameters[0].c_str()[0] != '#')
+ {
+ User* target = ServerInstance->FindNickOnly(parameters[0]);
+ if ((!target) || (target->registered != REG_ALL))
+ {
+ user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
+ return CMD_FAILURE;
+ }
+ }
User* target = ServerInstance->FindNick(parameters[0]);
if ((target) && (target != user))
{
diff --git a/src/modules/m_saquit.cpp b/src/modules/m_saquit.cpp
index 3050e70d6..aa6aa0180 100644
--- a/src/modules/m_saquit.cpp
+++ b/src/modules/m_saquit.cpp
@@ -35,7 +35,7 @@ class CommandSaquit : public Command
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
{
User* dest = ServerInstance->FindNick(parameters[0]);
- if ((dest) && (!IS_SERVER(dest)))
+ if ((dest) && (!IS_SERVER(dest)) && (dest->registered == REG_ALL))
{
if (dest->server->IsULine())
{
diff --git a/src/modules/m_spanningtree/idle.cpp b/src/modules/m_spanningtree/idle.cpp
index d7c0cdf1b..1b020701b 100644
--- a/src/modules/m_spanningtree/idle.cpp
+++ b/src/modules/m_spanningtree/idle.cpp
@@ -35,7 +35,7 @@ CmdResult CommandIdle::HandleRemote(RemoteUser* issuer, std::vector<std::string>
*/
User* target = ServerInstance->FindUUID(params[0]);
- if ((!target) || (IS_SERVER(target)))
+ if ((!target) || (IS_SERVER(target) || (target->registered != REG_ALL)))
return CMD_FAILURE;
LocalUser* localtarget = IS_LOCAL(target);
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index 9c262f1ea..9da06e829 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -188,7 +188,7 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
}
else
{
- ServerInstance->SNO->WriteGlobalSno('L', "Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
+ ServerInstance->SNO->WriteToSnoMask('L', "Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
}
int num_lost_servers = 0;
int num_lost_users = 0;
@@ -204,8 +204,9 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
Current->Tidy();
Current->GetParent()->DelChild(Current);
Current->cull();
+ const bool ismyroot = (Current == MyRoot);
delete Current;
- if (Current == MyRoot)
+ if (ismyroot)
{
MyRoot = NULL;
Close();
diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp
index 6c7000a77..57ca18a8f 100644
--- a/src/modules/m_watch.cpp
+++ b/src/modules/m_watch.cpp
@@ -231,7 +231,7 @@ class CommandWatch : public Command
}
User* target = ServerInstance->FindNick(nick);
- if (target)
+ if ((target) && (target->registered == REG_ALL))
{
(*wl)[nick] = std::string(target->ident).append(" ").append(target->dhost).append(" ").append(ConvToStr(target->age));
user->WriteNumeric(604, "%s %s :is online", nick, (*wl)[nick].c_str());
@@ -308,10 +308,10 @@ class CommandWatch : public Command
{
for (watchlist::iterator q = wl->begin(); q != wl->end(); q++)
{
- if (!q->second.empty())
+ User* targ = ServerInstance->FindNick(q->first.c_str());
+ if (targ && !q->second.empty())
{
user->WriteNumeric(604, "%s %s :is online", q->first.c_str(), q->second.c_str());
- User *targ = ServerInstance->FindNick(q->first.c_str());
if (targ->IsAway())
{
user->WriteNumeric(609, "%s %s %s %lu :is away", targ->nick.c_str(), targ->ident.c_str(), targ->dhost.c_str(), (unsigned long) targ->awaytime);
diff --git a/src/socket.cpp b/src/socket.cpp
index ba35d2b0a..4ff43cde7 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -219,8 +219,6 @@ bool irc::sockets::satoap(const irc::sockets::sockaddrs& sa, std::string& addr,
return !addr.empty();
}
-static const char all_zero[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 };
-
std::string irc::sockets::sockaddrs::str() const
{
if (sa.sa_family == AF_INET)
diff --git a/src/socketengines/socketengine_select.cpp b/src/socketengines/socketengine_select.cpp
index 79f1b3635..be4a7d186 100644
--- a/src/socketengines/socketengine_select.cpp
+++ b/src/socketengines/socketengine_select.cpp
@@ -111,7 +111,9 @@ void SocketEngine::OnSetEvent(EventHandler* eh, int old_mask, int new_mask)
int SocketEngine::DispatchEvents()
{
- static timeval tval = { 1, 0 };
+ timeval tval;
+ tval.tv_sec = 1;
+ tval.tv_usec = 0;
fd_set rfdset = ReadSet, wfdset = WriteSet, errfdset = ErrSet;