diff options
Diffstat (limited to 'src')
44 files changed, 135 insertions, 172 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index f0cd66dbf..d03f80f64 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -25,7 +25,7 @@ Channel::Channel(InspIRCd* Instance, const std::string &cname, time_t ts) : Serv throw CoreException("Cannot create duplicate channel " + cname); (*(ServerInstance->chanlist))[cname.c_str()] = this; - this->name.assign(cname, 0, CHANMAX); + this->name.assign(cname, 0, ServerInstance->Config->Limits.ChanMax); this->created = ts ? ts : ServerInstance->Time(); this->age = this->created; @@ -254,7 +254,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool } } - strlcpy(cname, cn, CHANMAX); + strlcpy(cname, cn, Instance->Config->Limits.ChanMax); Ptr = Instance->FindChan(cname); if (!Ptr) @@ -917,7 +917,7 @@ void Channel::UserList(User *user, CUList *ulist) size_t ptrlen = 0; - if (curlen > (480-NICKMAX)) + if (curlen + prefixlist.length() + nick.length() + 1 > 480) { /* list overflowed into multiple numerics */ user->WriteServ(std::string(list)); diff --git a/src/commands/cmd_away.cpp b/src/commands/cmd_away.cpp index 7fac7ae6d..6dccf9759 100644 --- a/src/commands/cmd_away.cpp +++ b/src/commands/cmd_away.cpp @@ -33,7 +33,7 @@ CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User return CMD_FAILURE; user->awaytime = ServerInstance->Time(); - user->awaymsg.assign(parameters[0], 0, MAXAWAY); + user->awaymsg.assign(parameters[0], 0, ServerInstance->Config->Limits.MaxAway); user->WriteNumeric(306, "%s :You have been marked as being away",user->nick.c_str()); } diff --git a/src/commands/cmd_join.cpp b/src/commands/cmd_join.cpp index b27007507..c19e7c015 100644 --- a/src/commands/cmd_join.cpp +++ b/src/commands/cmd_join.cpp @@ -28,7 +28,7 @@ CmdResult CommandJoin::Handle (const std::vector<std::string>& parameters, User if (ServerInstance->Parser->LoopCall(user, this, parameters, 0, 1)) return CMD_SUCCESS; - if (ServerInstance->IsChannel(parameters[0].c_str())) + if (ServerInstance->IsChannel(parameters[0].c_str(), ServerInstance->Config->Limits.ChanMax)) { Channel::JoinUser(ServerInstance, user, parameters[0].c_str(), false, parameters[1].c_str(), false); return CMD_SUCCESS; @@ -39,7 +39,7 @@ CmdResult CommandJoin::Handle (const std::vector<std::string>& parameters, User if (ServerInstance->Parser->LoopCall(user, this, parameters, 0)) return CMD_SUCCESS; - if (ServerInstance->IsChannel(parameters[0].c_str())) + if (ServerInstance->IsChannel(parameters[0].c_str(), ServerInstance->Config->Limits.ChanMax)) { Channel::JoinUser(ServerInstance, user, parameters[0].c_str(), false, "", false); return CMD_SUCCESS; diff --git a/src/commands/cmd_kick.cpp b/src/commands/cmd_kick.cpp index 174800cf5..a0ff5d1c3 100644 --- a/src/commands/cmd_kick.cpp +++ b/src/commands/cmd_kick.cpp @@ -23,7 +23,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) */ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User *user) { - char reason[MAXKICK]; + std::string reason; Channel* c = ServerInstance->FindChan(parameters[0]); User* u = ServerInstance->FindNick(parameters[1]); @@ -44,14 +44,14 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User if (parameters.size() > 2) { - strlcpy(reason, parameters[2].c_str(), MAXKICK - 1); + reason.assign(parameters[2], 0, ServerInstance->Config->Limits.MaxKick); } else { - strlcpy(reason, user->nick.c_str(), MAXKICK - 1); + reason.assign(user->nick, 0, ServerInstance->Config->Limits.MaxKick); } - if (!c->KickUser(user, u, reason)) + if (!c->KickUser(user, u, reason.c_str())) /* Nobody left here, delete the Channel */ delete c; diff --git a/src/commands/cmd_kill.cpp b/src/commands/cmd_kill.cpp index f656c5701..02e80b4f2 100644 --- a/src/commands/cmd_kill.cpp +++ b/src/commands/cmd_kill.cpp @@ -54,18 +54,18 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User if (*ServerInstance->Config->HideKillsServer) { // hidekills is on, use it - snprintf(killreason, MAXQUIT, "Killed (%s (%s))", ServerInstance->Config->HideKillsServer, parameters[1].c_str()); + snprintf(killreason, ServerInstance->Config->Limits.MaxQuit, "Killed (%s (%s))", ServerInstance->Config->HideKillsServer, parameters[1].c_str()); } else { // hidekills is off, do nothing - snprintf(killreason, MAXQUIT, "Killed (%s (%s))", user->nick.c_str(), parameters[1].c_str()); + snprintf(killreason, ServerInstance->Config->Limits.MaxQuit, "Killed (%s (%s))", user->nick.c_str(), parameters[1].c_str()); } } else { /* Leave it alone, remote server has already formatted it */ - strlcpy(killreason, parameters[1].c_str(), MAXQUIT); + strlcpy(killreason, parameters[1].c_str(), ServerInstance->Config->Limits.MaxQuit); } /* diff --git a/src/commands/cmd_nick.cpp b/src/commands/cmd_nick.cpp index 0391323dc..0eb55ccfe 100644 --- a/src/commands/cmd_nick.cpp +++ b/src/commands/cmd_nick.cpp @@ -27,7 +27,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) */ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User *user) { - char oldnick[NICKMAX]; + std::string oldnick; if (parameters[0].empty()) { @@ -36,7 +36,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User return CMD_FAILURE; } - if (((!ServerInstance->IsNick(parameters[0].c_str()))) && (IS_LOCAL(user))) + if (((!ServerInstance->IsNick(parameters[0].c_str(), ServerInstance->Config->Limits.NickMax))) && (IS_LOCAL(user))) { if (!allowinvalid) { @@ -59,11 +59,9 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User if (assign(user->nick) == parameters[0]) { - ServerInstance->Logs->Log("nick", DEBUG, "Change to same nick '%s' %d '%s' '%d'", user->nick.c_str(), user->nick.length(), parameters[0].c_str(), parameters[0].length()); /* If its exactly the same, even case, dont do anything. */ if (parameters[0] == user->nick) { - ServerInstance->Logs->Log("nick", DEBUG, "Not even a case change"); return CMD_SUCCESS; } @@ -71,14 +69,14 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User * able to do silly things like this even though the RFC says * the nick AAA is the same as the nick aaa. */ - strlcpy(oldnick, user->nick.c_str(), NICKMAX - 1); + oldnick.assign(user->nick, 0, ServerInstance->Config->Limits.NickMax); int MOD_RESULT = 0; - FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user,parameters[0].c_str())); + FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user,parameters[0])); if (MOD_RESULT) return CMD_FAILURE; if (user->registered == REG_ALL) user->WriteCommon("NICK %s",parameters[0].c_str()); - user->nick.assign(parameters[0], 0, NICKMAX - 1); + user->nick.assign(parameters[0], 0, ServerInstance->Config->Limits.NickMax); user->InvalidateCache(); FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(user,oldnick)); return CMD_SUCCESS; @@ -122,7 +120,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User InUse->WriteTo(InUse, "NICK %s", InUse->uuid.c_str()); InUse->WriteNumeric(433, "%s %s :Nickname overruled.", InUse->nick.c_str(), InUse->nick.c_str()); InUse->UpdateNickHash(InUse->uuid.c_str()); - InUse->nick.assign(InUse->uuid, 0, NICKMAX - 1); + InUse->nick.assign(InUse->uuid, 0, ServerInstance->Config->Limits.NickMax); InUse->InvalidateCache(); InUse->registered &= ~REG_NICK; } @@ -145,7 +143,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User if (user->registered == REG_ALL) user->WriteCommon("NICK %s", parameters[0].c_str()); - strlcpy(oldnick, user->nick.c_str(), NICKMAX - 1); + oldnick.assign(user->nick, 0, ServerInstance->Config->Limits.NickMax); /* change the nick of the user in the users_hash */ user = user->UpdateNickHash(parameters[0].c_str()); @@ -154,7 +152,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User if (!user) return CMD_FAILURE; - user->nick.assign(parameters[0], 0, NICKMAX - 1); + user->nick.assign(parameters[0], 0, ServerInstance->Config->Limits.NickMax); user->InvalidateCache(); /* Update display nicks */ @@ -181,7 +179,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User if (user->registered == REG_ALL) { user->IncreasePenalty(10); - FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(user,oldnick)); + FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(user, oldnick)); } return CMD_SUCCESS; diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp index 5086f3f4f..9cf4800a4 100644 --- a/src/commands/cmd_notice.cpp +++ b/src/commands/cmd_notice.cpp @@ -130,8 +130,9 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use if (targetserver) { - char nickonly[NICKMAX+1]; - strlcpy(nickonly, destnick, targetserver - destnick + 1); + std::string nickonly; + + nickonly.assign(destnick, 0, targetserver - destnick + 1); dest = ServerInstance->FindNickOnly(nickonly); if (dest && strcasecmp(dest->server, targetserver + 1)) { diff --git a/src/commands/cmd_oper.cpp b/src/commands/cmd_oper.cpp index 1ce7dc49d..97134f038 100644 --- a/src/commands/cmd_oper.cpp +++ b/src/commands/cmd_oper.cpp @@ -80,7 +80,7 @@ CmdResult CommandOper::Handle (const std::vector<std::string>& parameters, User if (!strcmp(TypeName,OperType)) { /* found this oper's opertype */ - if (!ServerInstance->IsNick(TypeName)) + if (!ServerInstance->IsNick(TypeName, ServerInstance->Config->Limits.NickMax)) { user->WriteNumeric(491, "%s :Invalid oper type (oper types must follow the same syntax as nicknames)",user->nick.c_str()); ServerInstance->SNO->WriteToSnoMask('o',"CONFIGURATION ERROR! Oper type '%s' contains invalid characters",OperType); diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp index 842635ae2..0086bb72d 100644 --- a/src/commands/cmd_privmsg.cpp +++ b/src/commands/cmd_privmsg.cpp @@ -132,8 +132,9 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us if (targetserver) { - char nickonly[NICKMAX+1]; - strlcpy(nickonly, destnick, targetserver - destnick + 1); + std::string nickonly; + + nickonly.assign(destnick, 0, targetserver - destnick + 1); dest = ServerInstance->FindNickOnly(nickonly); if (dest && strcasecmp(dest->server, targetserver + 1)) { diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index 9da5f1aeb..fafa97581 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -264,10 +264,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str for (std::vector<User*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++) { User* i = *n; - if (ServerInstance->IsNick(i->nick.c_str())) - { - results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->dhost+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age)); - } + results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->dhost+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age)); } break; @@ -277,10 +274,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str for (std::vector<User*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++) { User* i = *n; - if (ServerInstance->IsNick(i->nick.c_str())) - { - results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->GetIPString()+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age)); - } + results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->GetIPString()+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age)); } break; diff --git a/src/commands/cmd_topic.cpp b/src/commands/cmd_topic.cpp index e723a50c9..0e1a115da 100644 --- a/src/commands/cmd_topic.cpp +++ b/src/commands/cmd_topic.cpp @@ -70,7 +70,7 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User } } - char topic[MAXTOPIC]; + std::string topic; if (IS_LOCAL(user)) { @@ -79,17 +79,17 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User */ int MOD_RESULT = 0; - strlcpy(topic, parameters[1].c_str(), MAXTOPIC); + topic.assign(parameters[1], 0, ServerInstance->Config->Limits.MaxTopic); FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic)); if (MOD_RESULT) return CMD_FAILURE; - Ptr->topic.assign(topic, 0, MAXTOPIC); + Ptr->topic.assign(topic, 0, ServerInstance->Config->Limits.MaxTopic); } else { /* Sneaky shortcut, one string copy for a remote topic */ - Ptr->topic.assign(parameters[1], 0, MAXTOPIC); + Ptr->topic.assign(parameters[1], 0, ServerInstance->Config->Limits.MaxTopic); } Ptr->setby.assign(ServerInstance->Config->FullHostInTopic ? diff --git a/src/commands/cmd_user.cpp b/src/commands/cmd_user.cpp index 1acd901f9..7bc9307f6 100644 --- a/src/commands/cmd_user.cpp +++ b/src/commands/cmd_user.cpp @@ -40,14 +40,14 @@ CmdResult CommandUser::Handle (const std::vector<std::string>& parameters, User * ~ character, and +1 for null termination, therefore we can safely use up to * IDENTMAX here. */ - user->ident.assign(parameters[0], 0, IDENTMAX); - user->fullname.assign(parameters[3].empty() ? std::string("No info") : parameters[3], 0, MAXGECOS); + user->ident.assign(parameters[0], 0, ServerInstance->Config->Limits.IdentMax); + user->fullname.assign(parameters[3].empty() ? std::string("No info") : parameters[3], 0, ServerInstance->Config->Limits.MaxGecos); user->registered = (user->registered | REG_USER); } } else { - user->WriteNumeric(462, "%s :You may not reregister",user->nick.c_str()); + user->WriteNumeric(462, "%s :You may not reregister", user->nick.c_str()); return CMD_FAILURE; } diff --git a/src/configreader.cpp b/src/configreader.cpp index e18435316..76aae190b 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -1009,7 +1009,7 @@ void ServerConfig::Read(bool bail, User* user) case DT_CHANNEL: { ValueContainerChar* vcc = (ValueContainerChar*)Values[Index].val; - if (*(vi.GetString()) && !ServerInstance->IsChannel(vi.GetString())) + if (*(vi.GetString()) && !ServerInstance->IsChannel(vi.GetString(), MAXBUF)) { ServerInstance->Threads->Mutex(false); throw CoreException("The value of <"+std::string(Values[Index].tag)+":"+Values[Index].value+"> is not a valid channel name"); @@ -1114,7 +1114,7 @@ void ServerConfig::Read(bool bail, User* user) vl.push_back(ValueItem(item)); else vl.push_back(ValueItem("")); - if (!ServerInstance->IsChannel(vl[vl.size()-1].GetString())) + if (!ServerInstance->IsChannel(vl[vl.size()-1].GetString(), MAXBUF)) throw CoreException("The value of <"+std::string(MultiValues[Index].tag)+":"+MultiValues[Index].items[valuenum]+"> number "+ConvToStr(tagnum + 1)+" is not a valid channel name"); } break; diff --git a/src/cull_list.cpp b/src/cull_list.cpp index ddbf6acae..a7f8d3316 100644 --- a/src/cull_list.cpp +++ b/src/cull_list.cpp @@ -54,8 +54,8 @@ int CullList::Apply() std::string reason; std::string oper_reason; - reason.assign(u->quitmsg, 0, MAXQUIT - 1); - oper_reason.assign(preset_reason.empty() ? preset_reason : u->operquitmsg, 0, MAXQUIT - 1); + reason.assign(u->quitmsg, 0, ServerInstance->Config->Limits.MaxQuit); + oper_reason.assign(preset_reason.empty() ? preset_reason : u->operquitmsg, 0, ServerInstance->Config->Limits.MaxQuit); if (u->registered != REG_ALL) if (ServerInstance->Users->unregistered_count) diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index a27a83f64..19f2d601c 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -318,7 +318,7 @@ CoreExport const char* irc::Spacify(const char* n) } -irc::modestacker::modestacker(bool add) : adding(add) +irc::modestacker::modestacker(InspIRCd* Instance, bool add) : ServerInstance(Instance), adding(add) { sequence.clear(); sequence.push_back(""); @@ -362,7 +362,7 @@ int irc::modestacker::GetStackedLine(std::deque<std::string> &result, int max_li if (sequence.size() > 1) nextsize = sequence[1].length() + 2; - while (!sequence[0].empty() && (sequence.size() > 1) && (result.size() < MAXMODES) && ((size + nextsize) < max_line_size)) + while (!sequence[0].empty() && (sequence.size() > 1) && (result.size() < ServerInstance->Config->Limits.MaxModes) && ((size + nextsize) < max_line_size)) { result[0] += *(sequence[0].begin()); if (!sequence[1].empty()) diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 8b93be245..d46f53ec7 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -182,9 +182,9 @@ bool InspIRCd::IsValidMask(const std::string &mask) } /* true for valid channel name, false else */ -bool IsChannelHandler::Call(const char *chname) +bool IsChannelHandler::Call(const char *chname, size_t max) { - char *c; + const char *c = chname + 1; /* check for no name - don't check for !*chname, as if it is empty, it won't be '#'! */ if (!chname || *chname != '#') @@ -192,7 +192,6 @@ bool IsChannelHandler::Call(const char *chname) return false; } - c = (char *)chname + 1; while (*c) { switch (*c) @@ -205,9 +204,10 @@ bool IsChannelHandler::Call(const char *chname) c++; } - + + size_t len = c - chname; /* too long a name - note funky pointer arithmetic here. */ - if ((c - chname) > CHANMAX) + if (len > max) { return false; } @@ -216,13 +216,13 @@ bool IsChannelHandler::Call(const char *chname) } /* true for valid nickname, false else */ -bool IsNickHandler::Call(const char* n) +bool IsNickHandler::Call(const char* n, size_t max) { if (!n || !*n) return false; - int p = 0; - for (char* i = (char*)n; *i; i++, p++) + unsigned int p = 0; + for (const char* i = n; *i; i++, p++) { if ((*i >= 'A') && (*i <= '}')) { @@ -241,7 +241,7 @@ bool IsNickHandler::Call(const char* n) } /* too long? or not -- pointer arithmetic rocks */ - return (p < NICKMAX - 1); + return (p < max); } /* return true for good ident, false else */ @@ -250,7 +250,7 @@ bool IsIdentHandler::Call(const char* n) if (!n || !*n) return false; - for (char* i = (char*)n; *i; i++) + for (const char* i = n; *i; i++) { if ((*i >= 'A') && (*i <= '}')) { diff --git a/src/mode.cpp b/src/mode.cpp index ed4b4b6b6..b778d1d5c 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -711,7 +711,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, state_change = false; if ((output_sequence.length() + parameter_list.str().length() > 450) || (output_sequence.length() > 100) - || (parameter_count > MAXMODES)) + || (parameter_count > ServerInstance->Config->Limits.MaxModes)) { /* We cant have a mode sequence this long */ letter = mode_sequence.end() - 1; diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index a8add0c72..f786d48ee 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -114,7 +114,7 @@ class BanRedirect : public ModeWatcher if(mask[CHAN].length()) { - if(Srv->IsChannel(mask[CHAN].c_str())) + if(!IS_LOCAL(source) || Srv->IsChannel(mask[CHAN].c_str(), ServerInstance->Config->Limits.ChanMax)) { if (assign(channel->name) == mask[CHAN]) { diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp index e44e496f8..a79eda993 100644 --- a/src/modules/m_chanprotect.cpp +++ b/src/modules/m_chanprotect.cpp @@ -68,7 +68,7 @@ class FounderProtectBase std::string item = extend + std::string(channel->name); std::vector<std::string> mode_junk; mode_junk.push_back(channel->name); - irc::modestacker modestack(false); + irc::modestacker modestack(ServerInstance, false); std::deque<std::string> stackresult; for (CUList::iterator i = cl->begin(); i != cl->end(); i++) diff --git a/src/modules/m_chgident.cpp b/src/modules/m_chgident.cpp index d0d77f193..3ab558b57 100644 --- a/src/modules/m_chgident.cpp +++ b/src/modules/m_chgident.cpp @@ -43,7 +43,7 @@ class CommandChgident : public Command return CMD_FAILURE; } - if (parameters[1].length() > IDENTMAX - 1) + if (parameters[1].length() > ServerInstance->Config->Limits.IdentMax) { user->WriteServ("NOTICE %s :*** CHGIDENT: Ident is too long", user->nick.c_str()); return CMD_FAILURE; diff --git a/src/modules/m_chgname.cpp b/src/modules/m_chgname.cpp index 233bb15b6..936cd72ac 100644 --- a/src/modules/m_chgname.cpp +++ b/src/modules/m_chgname.cpp @@ -43,7 +43,7 @@ class CommandChgname : public Command return CMD_FAILURE; } - if (parameters[1].length() > MAXGECOS) + if (parameters[1].length() > ServerInstance->Config->Limits.MaxGecos) { user->WriteServ("NOTICE %s :*** GECOS too long", user->nick.c_str()); return CMD_FAILURE; diff --git a/src/modules/m_conn_join.cpp b/src/modules/m_conn_join.cpp index 139414155..046176b0c 100644 --- a/src/modules/m_conn_join.cpp +++ b/src/modules/m_conn_join.cpp @@ -81,7 +81,7 @@ class ModuleConnJoin : public Module return; for(std::vector<std::string>::iterator it = Joinchans.begin(); it != Joinchans.end(); it++) - if (ServerInstance->IsChannel(it->c_str())) + if (ServerInstance->IsChannel(it->c_str(), ServerInstance->Config->Limits.ChanMax)) Channel::JoinUser(ServerInstance, user, it->c_str(), false, "", false, ServerInstance->Time()); } diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp index f28547679..e847f8c7c 100644 --- a/src/modules/m_denychans.cpp +++ b/src/modules/m_denychans.cpp @@ -45,7 +45,7 @@ class ModuleDenyChannels : public Module if (!redirect.empty()) { - if (!ServerInstance->IsChannel(redirect.c_str())) + if (!ServerInstance->IsChannel(redirect.c_str(), ServerInstance->Config->Limits.ChanMax)) { if (user) user->WriteServ("Notice %s :Invalid badchan redirect '%s'", user->nick.c_str(), redirect.c_str()); @@ -110,7 +110,7 @@ class ModuleDenyChannels : public Module } } - if (ServerInstance->IsChannel(redirect.c_str())) + if (ServerInstance->IsChannel(redirect.c_str(), ServerInstance->Config->Limits.ChanMax)) { /* simple way to avoid potential loops: don't redirect to +L channels */ Channel *newchan = ServerInstance->FindChan(redirect); diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index e7d8728d6..197a6e5e2 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -296,11 +296,11 @@ class IdentRequestSocket : public EventHandler if (i < 3) continue; - char ident[IDENTMAX + 2]; + std::string ident; /* Truncate the ident at any characters we don't like, skip leading spaces */ - int k = 0; - for (const char *j = token.c_str(); *j && (k < IDENTMAX + 1); j++) + size_t k = 0; + for (const char *j = token.c_str(); *j && (k < ServerInstance->Config->Limits.IdentMax + 1); j++) { if (*j == ' ') continue; @@ -308,17 +308,15 @@ class IdentRequestSocket : public EventHandler /* Rules taken from InspIRCd::IsIdent */ if (((*j >= 'A') && (*j <= '}')) || ((*j >= '0') && (*j <= '9')) || (*j == '-') || (*j == '.')) { - ident[k++] = *j; + ident += *j; continue; } break; } - ident[k] = '\0'; - /* Re-check with IsIdent, in case that changes and this doesn't (paranoia!) */ - if (*ident && ServerInstance->IsIdent(ident)) + if (!ident.empty() && ServerInstance->IsIdent(ident.c_str())) { result = ident; } @@ -366,9 +364,9 @@ class ModuleIdent : public Module virtual int OnUserRegister(User *user) { /* User::ident is currently the username field from USER; with m_ident loaded, that - * should be preceded by a ~. The field is actually IDENTMAX+2 characters wide. */ - if (user->ident.length() > IDENTMAX + 1) - user->ident.assign(user->ident, 0, IDENTMAX); + * should be preceded by a ~. The field is actually IdentMax+2 characters wide. */ + if (user->ident.length() > ServerInstance->Config->Limits.IdentMax + 1) + user->ident.assign(user->ident, 0, ServerInstance->Config->Limits.IdentMax); user->ident.insert(0, "~"); user->WriteServ("NOTICE Auth :*** Looking up your ident..."); @@ -457,7 +455,7 @@ class ModuleIdent : public Module user->WriteServ("NOTICE Auth :*** Could not find your ident, using %s instead.", isock->GetResult()); /* Copy the ident string to the user */ - user->ident.assign(isock->GetResult(), 0, IDENTMAX+1); + user->ident.assign(isock->GetResult(), 0, ServerInstance->Config->Limits.IdentMax + 1); /* The user isnt actually disconnecting, we call this to clean up the user */ OnUserDisconnect(user); diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp index adeab2691..86054ab3e 100644 --- a/src/modules/m_nicklock.cpp +++ b/src/modules/m_nicklock.cpp @@ -48,7 +48,7 @@ class CommandNicklock : public Command } // check nick is valid - if (!ServerInstance->IsNick(parameters[1].c_str())) + if (IS_LOCAL(user) && !ServerInstance->IsNick(parameters[1].c_str(), ServerInstance->Config->Limits.NickMax)) { return CMD_FAILURE; } @@ -58,8 +58,12 @@ class CommandNicklock : public Command if (!target->ForceNickChange(parameters[1].c_str())) { - // ugh, nickchange failed for some reason -- possibly existing nick? XXX change to UID here - ServerInstance->Users->QuitUser(target, "Nickname collision"); + // ugh, nickchange failed for some reason -- possibly existing nick? + if (!target->ForceNickChange(target->uuid.c_str())) + { + // Well shit, we cant even change them to their UID (this should not happen!) + ServerInstance->Users->QuitUser(target, "Nickname collision"); + } } // give them a lock flag diff --git a/src/modules/m_operjoin.cpp b/src/modules/m_operjoin.cpp index 42415faa2..b0976b1cc 100644 --- a/src/modules/m_operjoin.cpp +++ b/src/modules/m_operjoin.cpp @@ -91,7 +91,7 @@ class ModuleOperjoin : public Module return; for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++) - if (ServerInstance->IsChannel(it->c_str())) + if (ServerInstance->IsChannel(it->c_str(), ServerInstance->Config->Limits.ChanMax)) Channel::JoinUser(ServerInstance, user, it->c_str(), override, "", false, ServerInstance->Time()); std::map<std::string, std::vector<std::string> >::iterator i = operTypeChans.find(user->oper); @@ -101,7 +101,7 @@ class ModuleOperjoin : public Module const std::vector<std::string>& list = i->second; for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it) { - if (ServerInstance->IsChannel(it->c_str())) + if (ServerInstance->IsChannel(it->c_str(), ServerInstance->Config->Limits.ChanMax)) { Channel::JoinUser(ServerInstance, user, it->c_str(), override, "", false, ServerInstance->Time()); } diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 289a73dca..9c529a37d 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -42,9 +42,9 @@ class Redirect : public ModeHandler { Channel* c = NULL; - if (!ServerInstance->IsChannel(parameter.c_str())) + if (IS_LOCAL(source) && !ServerInstance->IsChannel(parameter.c_str(), ServerInstance->Config->Limits.ChanMax)) { - source->WriteNumeric(403, "%s %s :Invalid channel name",source->nick.c_str(), parameter.c_str()); + source->WriteNumeric(403, "%s %s :Invalid channel name", source->nick.c_str(), parameter.c_str()); parameter.clear(); return MODEACTION_DENY; } diff --git a/src/modules/m_sajoin.cpp b/src/modules/m_sajoin.cpp index 8b237674b..5be61fbf6 100644 --- a/src/modules/m_sajoin.cpp +++ b/src/modules/m_sajoin.cpp @@ -37,10 +37,10 @@ class CommandSajoin : public Command user->WriteNumeric(990, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str()); return CMD_FAILURE; } - if (!ServerInstance->IsChannel(parameters[1].c_str())) + if (IS_LOCAL(source) && !ServerInstance->IsChannel(parameters[1].c_str(), ServerInstance->Config->Limits.ChanMax)) { /* we didn't need to check this for each character ;) */ - user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name"); + user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name or name too long"); return CMD_FAILURE; } diff --git a/src/modules/m_sanick.cpp b/src/modules/m_sanick.cpp index cd93377c8..83d7fabd4 100644 --- a/src/modules/m_sanick.cpp +++ b/src/modules/m_sanick.cpp @@ -38,7 +38,11 @@ class CommandSanick : public Command return CMD_FAILURE; } std::string oldnick = user->nick; - if (ServerInstance->IsNick(parameters[1].c_str())) + if (IS_LOCAL(user) && !ServerInstance->IsNick(parameters[1].c_str(), ServerInstance->Config->Limits.NickMax)) + { + user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick.c_str(), parameters[1].c_str()); + } + else { if (target->ForceNickChange(parameters[1].c_str())) { @@ -52,10 +56,6 @@ class CommandSanick : public Command return CMD_FAILURE; } } - else - { - user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick.c_str(), parameters[1].c_str()); - } return CMD_FAILURE; } diff --git a/src/modules/m_setident.cpp b/src/modules/m_setident.cpp index 13f5d0c92..6577ebbb3 100644 --- a/src/modules/m_setident.cpp +++ b/src/modules/m_setident.cpp @@ -35,7 +35,7 @@ class CommandSetident : public Command return CMD_FAILURE; } - if (parameters[0].size() > IDENTMAX) + if (parameters[0].size() > ServerInstance->Config->Limits.IdentMax) { user->WriteServ("NOTICE %s :*** SETIDENT: Ident is too long", user->nick.c_str()); return CMD_FAILURE; diff --git a/src/modules/m_setname.cpp b/src/modules/m_setname.cpp index eab376cab..8c35c2be2 100644 --- a/src/modules/m_setname.cpp +++ b/src/modules/m_setname.cpp @@ -35,7 +35,7 @@ class CommandSetname : public Command return CMD_FAILURE; } - if (parameters[0].size() > MAXGECOS) + if (parameters[0].size() > ServerInstance->Config->Limits.MaxGecos) { user->WriteServ("NOTICE %s :*** SETNAME: GECOS too long", user->nick.c_str()); return CMD_FAILURE; diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp index 5919c65bb..9a45b8131 100644 --- a/src/modules/m_spanningtree/capab.cpp +++ b/src/modules/m_spanningtree/capab.cpp @@ -81,16 +81,16 @@ void TreeSocket::SendCapabilities() } this->WriteLine("CAPAB CAPABILITIES " /* Preprocessor does this one. */ - ":NICKMAX="+ConvToStr(NICKMAX)+ - " HALFOP="+ConvToStr(this->Instance->Config->AllowHalfop)+ - " CHANMAX="+ConvToStr(CHANMAX)+ - " MAXMODES="+ConvToStr(MAXMODES)+ - " IDENTMAX="+ConvToStr(IDENTMAX)+ - " MAXQUIT="+ConvToStr(MAXQUIT)+ - " MAXTOPIC="+ConvToStr(MAXTOPIC)+ - " MAXKICK="+ConvToStr(MAXKICK)+ - " MAXGECOS="+ConvToStr(MAXGECOS)+ - " MAXAWAY="+ConvToStr(MAXAWAY)+ + ":NICKMAX="+ConvToStr(Instance->Config->Limits.NickMax)+ + " HALFOP="+ConvToStr(Instance->Config->AllowHalfop)+ + " CHANMAX="+ConvToStr(Instance->Config->Limits.ChanMax)+ + " MAXMODES="+ConvToStr(Instance->Config->Limits.MaxModes)+ + " IDENTMAX="+ConvToStr(Instance->Config->Limits.IdentMax)+ + " MAXQUIT="+ConvToStr(Instance->Config->Limits.MaxQuit)+ + " MAXTOPIC="+ConvToStr(Instance->Config->Limits.MaxTopic)+ + " MAXKICK="+ConvToStr(Instance->Config->Limits.MaxKick)+ + " MAXGECOS="+ConvToStr(Instance->Config->Limits.MaxGecos)+ + " MAXAWAY="+ConvToStr(Instance->Config->Limits.MaxAway)+ " IP6NATIVE="+ConvToStr(ip6)+ " IP6SUPPORT="+ConvToStr(ip6support)+ " PROTOCOL="+ConvToStr(ProtocolVersion)+extra+ @@ -171,19 +171,6 @@ bool TreeSocket::Capab(const std::deque<std::string> ¶ms) reason = "Modules loaded on these servers are not correctly matched, these modules are not loaded on " + diff; } - cap_validation valid_capab[] = { - {"Maximum nickname lengths differ or remote nickname length not specified", "NICKMAX", NICKMAX}, - {"Maximum ident lengths differ or remote ident length not specified", "IDENTMAX", IDENTMAX}, - {"Maximum channel lengths differ or remote channel length not specified", "CHANMAX", CHANMAX}, - {"Maximum modes per line differ or remote modes per line not specified", "MAXMODES", MAXMODES}, - {"Maximum quit lengths differ or remote quit length not specified", "MAXQUIT", MAXQUIT}, - {"Maximum topic lengths differ or remote topic length not specified", "MAXTOPIC", MAXTOPIC}, - {"Maximum kick lengths differ or remote kick length not specified", "MAXKICK", MAXKICK}, - {"Maximum GECOS (fullname) lengths differ or remote GECOS length not specified", "MAXGECOS", MAXGECOS}, - {"Maximum awaymessage lengths differ or remote awaymessage length not specified", "MAXAWAY", MAXAWAY}, - {"", "", 0} - }; - if (((this->CapKeys.find("IP6SUPPORT") == this->CapKeys.end()) && (ip6support)) || ((this->CapKeys.find("IP6SUPPORT") != this->CapKeys.end()) && (this->CapKeys.find("IP6SUPPORT")->second != ConvToStr(ip6support)))) reason = "We don't both support linking to IPV6 servers"; if (((this->CapKeys.find("IP6NATIVE") != this->CapKeys.end()) && (this->CapKeys.find("IP6NATIVE")->second == "1")) && (!ip6support)) @@ -201,13 +188,6 @@ bool TreeSocket::Capab(const std::deque<std::string> ¶ms) if (((this->CapKeys.find("HALFOP") == this->CapKeys.end()) && (Instance->Config->AllowHalfop)) || ((this->CapKeys.find("HALFOP") != this->CapKeys.end()) && (this->CapKeys.find("HALFOP")->second != ConvToStr(Instance->Config->AllowHalfop)))) reason = "We don't both have halfop support enabled/disabled identically"; - - for (int x = 0; valid_capab[x].size; ++x) - { - if (((this->CapKeys.find(valid_capab[x].key) == this->CapKeys.end()) || ((this->CapKeys.find(valid_capab[x].key) != this->CapKeys.end()) && - (this->CapKeys.find(valid_capab[x].key)->second != ConvToStr(valid_capab[x].size))))) - reason = valid_capab[x].reason; - } /* Challenge response, store their challenge for our password */ std::map<std::string,std::string>::iterator n = this->CapKeys.find("CHALLENGE"); diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index 985c86143..4ef8d2d4f 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -60,7 +60,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p if (params.size() < 3) return true; - irc::modestacker modestack(true); /* Modes to apply from the users in the user list */ + irc::modestacker modestack(Instance, true); /* Modes to apply from the users in the user list */ User* who = NULL; /* User we are currently checking */ std::string channel = params[0]; /* Channel name, as a string */ time_t TS = atoi(params[1].c_str()); /* Timestamp given to us for remote side */ diff --git a/src/modules/m_spanningtree/ftopic.cpp b/src/modules/m_spanningtree/ftopic.cpp index 3ea775112..e18187087 100644 --- a/src/modules/m_spanningtree/ftopic.cpp +++ b/src/modules/m_spanningtree/ftopic.cpp @@ -34,7 +34,7 @@ bool TreeSocket::ForceTopic(const std::string &source, std::deque<std::string> & if ((ts >= c->topicset) || (c->topic.empty())) { std::string oldtopic = c->topic; - c->topic.assign(params[3], 0, MAXTOPIC); + c->topic.assign(params[3], 0, Instance->Config->Limits.MaxTopic); c->setby.assign(params[2], 0, 127); c->topicset = ts; /* if the topic text is the same as the current topic, diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 8444bbec6..793a3cf9a 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -96,8 +96,19 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) { + size_t ptrlen = 0; + std::string modestr = this->Instance->Modes->ModeString(i->first, c, false); + + if ((curlen + modestr.length() + i->first->uuid.length() + 4) > 480) + { + buffer.append(list).append("\r\n"); + dlen = curlen = snprintf(list, MAXBUF, ":%s FJOIN %s %lu +%s", this->Instance->Config->GetSID().c_str(), c->name.c_str(), (unsigned long)c->age, c->ChanModes(true)); + ptr = list + dlen; + numusers = 0; + } + // The first parameter gets a : before it - size_t ptrlen = snprintf(ptr, MAXBUF, " %s%s,%s", !numusers ? ":" : "", this->Instance->Modes->ModeString(i->first, c, false).c_str(), i->first->uuid.c_str()); + ptrlen = snprintf(ptr, MAXBUF, " %s%s,%s", !numusers ? ":" : "", modestr.c_str(), i->first->uuid.c_str()); looped_once = true; @@ -105,15 +116,6 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) ptr += ptrlen; numusers++; - - if (curlen > (480-NICKMAX)) - { - buffer.append(list).append("\r\n"); - dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu +%s", this->Instance->Config->GetSID().c_str(), c->name.c_str(), (unsigned long)c->age, c->ChanModes(true)); - ptr = list + dlen; - ptrlen = 0; - numusers = 0; - } } // Okay, permanent channels will (of course) need this \r\n anyway, numusers check is if there @@ -132,7 +134,7 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) params.append(" ").append(b->data); linesize += size; } - if ((params.length() >= MAXMODES) || (currsize > 350)) + if ((params.length() >= Instance->Config->Limits.MaxModes) || (currsize > 350)) { /* Wrap at MAXMODES */ buffer.append(":").append(this->Instance->Config->GetSID()).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params).append("\r\n"); diff --git a/src/modules/m_spanningtree/opertype.cpp b/src/modules/m_spanningtree/opertype.cpp index a2aff74f9..01638f9ac 100644 --- a/src/modules/m_spanningtree/opertype.cpp +++ b/src/modules/m_spanningtree/opertype.cpp @@ -35,8 +35,8 @@ bool TreeSocket::OperType(const std::string &prefix, std::deque<std::string> &pa if (!u->IsModeSet('o')) this->Instance->Users->all_opers.push_back(u); u->modes[UM_OPERATOR] = 1; - u->oper.assign(opertype, 0, NICKMAX - 1); - Utils->DoOneToAllButSender(u->uuid,"OPERTYPE",params,u->server); + u->oper.assign(opertype, 0, Instance->Config->Limits.NickMax); + Utils->DoOneToAllButSender(u->uuid, "OPERTYPE", params, u->server); TreeServer* remoteserver = Utils->FindServer(u->server); bool dosend = true; diff --git a/src/modules/m_spanningtree/svsjoin.cpp b/src/modules/m_spanningtree/svsjoin.cpp index ee4addb74..5f9f94e95 100644 --- a/src/modules/m_spanningtree/svsjoin.cpp +++ b/src/modules/m_spanningtree/svsjoin.cpp @@ -35,9 +35,6 @@ bool TreeSocket::ServiceJoin(const std::string &prefix, std::deque<std::string> if (params.size() < 2) return true; - if (!this->Instance->IsChannel(params[1].c_str())) - return true; - User* u = this->Instance->FindNick(params[0]); if (u) diff --git a/src/modules/m_spanningtree/svspart.cpp b/src/modules/m_spanningtree/svspart.cpp index 00fd9eb3a..639792be9 100644 --- a/src/modules/m_spanningtree/svspart.cpp +++ b/src/modules/m_spanningtree/svspart.cpp @@ -35,9 +35,6 @@ bool TreeSocket::ServicePart(const std::string &prefix, std::deque<std::string> if (params.size() < 2) return true; - if (!this->Instance->IsChannel(params[1].c_str())) - return true; - User* u = this->Instance->FindNick(params[0]); Channel* c = this->Instance->FindChan(params[1]); diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index 70f7b874c..d84ee2a04 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -48,9 +48,6 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa time_t signon = ConvToInt(params[8]); std::string empty; - /* XXX probably validate UID length too -- w00t */ - cmd_validation valid[] = { {"Nickname", 2, NICKMAX}, {"Hostname", 3, 64}, {"Displayed hostname", 4, 64}, {"Ident", 5, IDENTMAX + 1}, {"GECOS", 9, MAXGECOS}, {"", 0, 0} }; - TreeServer* remoteserver = Utils->FindServer(source); if (!remoteserver) @@ -66,16 +63,6 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa return true; } - for (size_t x = 0; valid[x].length; ++x) - { - if (params[valid[x].param].length() > valid[x].length) - { - this->WriteLine(std::string(":")+this->Instance->Config->GetSID()+" KILL "+params[0]+" :Invalid client introduction (" + valid[x].item + " > " + ConvToStr(valid[x].length) + ")"); - return true; - } - } - - /* check for collision */ user_hash::iterator iter = this->Instance->Users->clientlist->find(params[2]); @@ -109,12 +96,12 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa } (*(this->Instance->Users->clientlist))[params[2]] = _new; _new->SetFd(FD_MAGIC_NUMBER); - _new->nick.assign(params[2], 0, NICKMAX - 1); + _new->nick.assign(params[2], 0, MAXBUF); _new->host.assign(params[3], 0, 64); _new->dhost.assign(params[4], 0, 64); _new->server = this->Instance->FindServerNamePtr(remoteserver->GetName().c_str()); - _new->ident.assign(params[5], 0, IDENTMAX + 1); - _new->fullname.assign(params[9], 0, MAXGECOS); + _new->ident.assign(params[5], 0, MAXBUF); + _new->fullname.assign(params[9], 0, MAXBUF); _new->registered = REG_ALL; _new->signon = signon; _new->age = age_t; diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp index ce19a67a3..c1c7e8421 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -100,7 +100,11 @@ class CommandSvshold : public Command else if (parameters.size() >= 2) { /* full form to add a SVSHold */ - if (ServerInstance->IsNick(parameters[0].c_str())) + + /* NOTE: We check nicks up to 512 in length here, as a hax to allow + * remote nicks that are longer than our configuration to be held + */ + if (ServerInstance->IsNick(parameters[0].c_str(), 512)) { // parameters[0] = w00t // parameters[1] = 1h3m2s diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index 3ae856b5e..62949e48a 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -137,7 +137,7 @@ class CommandWatch : public Command CmdResult remove_watch(User* user, const char* nick) { // removing an item from the list - if (!ServerInstance->IsNick(nick)) + if (!ServerInstance->IsNick(nick, ServerInstance->Config->Limits.NickMax)) { user->WriteNumeric(942, "%s %s :Invalid nickname", user->nick.c_str(), nick); return CMD_FAILURE; @@ -191,7 +191,7 @@ class CommandWatch : public Command CmdResult add_watch(User* user, const char* nick) { - if (!ServerInstance->IsNick(nick)) + if (!ServerInstance->IsNick(nick, ServerInstance->Config->Limits.NickMax)) { user->WriteNumeric(942, "%s %s :Invalid nickname",user->nick.c_str(),nick); return CMD_FAILURE; diff --git a/src/server.cpp b/src/server.cpp index ae1d106b8..d583d87c3 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -83,9 +83,9 @@ void InspIRCd::BuildISupport() { // the neatest way to construct the initial 005 numeric, considering the number of configure constants to go in it... std::stringstream v; - v << "WALLCHOPS WALLVOICES MODES=" << MAXMODES << " CHANTYPES=# PREFIX=" << this->Modes->BuildPrefixes() << " MAP MAXCHANNELS=" << Config->MaxChans << " MAXBANS=60 VBANLIST NICKLEN=" << NICKMAX-1; - v << " CASEMAPPING=rfc1459 STATUSMSG=@" << (this->Config->AllowHalfop ? "%" : "") << "+ CHARSET=ascii TOPICLEN=" << MAXTOPIC << " KICKLEN=" << MAXKICK << " MAXTARGETS=" << Config->MaxTargets; - v << " AWAYLEN=" << MAXAWAY << " CHANMODES=" << this->Modes->ChanModes() << " FNC NETWORK=" << Config->Network << " MAXPARA=32 ELIST=MU"; + v << "WALLCHOPS WALLVOICES MODES=" << Config->Limits.MaxModes << " CHANTYPES=# PREFIX=" << this->Modes->BuildPrefixes() << " MAP MAXCHANNELS=" << Config->MaxChans << " MAXBANS=60 VBANLIST NICKLEN=" << Config->Limits.NickMax; + v << " CASEMAPPING=rfc1459 STATUSMSG=@" << (this->Config->AllowHalfop ? "%" : "") << "+ CHARSET=ascii TOPICLEN=" << Config->Limits.MaxTopic << " KICKLEN=" << Config->Limits.MaxKick << " MAXTARGETS=" << Config->MaxTargets; + v << " AWAYLEN=" << Config->Limits.MaxAway << " CHANMODES=" << this->Modes->ChanModes() << " FNC NETWORK=" << Config->Network << " MAXPARA=32 ELIST=MU"; Config->data005 = v.str(); FOREACH_MOD_I(this,I_On005Numeric,On005Numeric(Config->data005)); Config->Update005(); diff --git a/src/usermanager.cpp b/src/usermanager.cpp index a171c32d2..73096d4a8 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -68,7 +68,7 @@ void UserManager::AddUser(InspIRCd* Instance, int socket, int port, bool iscache (*(this->clientlist))[New->uuid] = New; /* The users default nick is their UUID */ - New->nick.assign(New->uuid, 0, NICKMAX - 1); + New->nick.assign(New->uuid, 0, ServerInstance->Config->Limits.NickMax); New->server = Instance->FindServerNamePtr(Instance->Config->ServerName); New->ident.assign("unknown"); diff --git a/src/users.cpp b/src/users.cpp index 4ffdeb678..c892c51f5 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -721,7 +721,7 @@ void User::Oper(const std::string &opertype, const std::string &opername) this->WriteServ("MODE %s :+o", this->nick.c_str()); FOREACH_MOD(I_OnOper, OnOper(this, opertype)); ServerInstance->Logs->Log("OPER", DEFAULT, "%s!%s@%s opered as type: %s", this->nick.c_str(), this->ident.c_str(), this->host.c_str(), opertype.c_str()); - this->oper.assign(opertype, 0, NICKMAX - 1); + this->oper.assign(opertype, 0, ServerInstance->Config->Limits.NickMax); ServerInstance->Users->all_opers.push_back(this); opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper.c_str()); @@ -1521,7 +1521,7 @@ bool User::ChangeName(const char* gecos) return false; FOREACH_MOD(I_OnChangeName,OnChangeName(this,gecos)); } - this->fullname.assign(gecos, 0, MAXGECOS+1); + this->fullname.assign(gecos, 0, ServerInstance->Config->Limits.MaxGecos); return true; } @@ -1573,7 +1573,7 @@ bool User::ChangeIdent(const char* newident) if (this->ServerInstance->Config->CycleHosts) this->WriteCommonExcept("%s","QUIT :Changing ident"); - this->ident.assign(newident, 0, IDENTMAX + 1); + this->ident.assign(newident, 0, ServerInstance->Config->Limits.IdentMax + 1); this->InvalidateCache(); |