diff options
author | attilamolnar <attilamolnar@hush.com> | 2012-07-04 20:12:42 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-04-12 21:03:03 +0200 |
commit | 19c695250f7504260b850f088d956d8a4099e73e (patch) | |
tree | 1c8108274276d9226984be3d881d39e7431a2416 /src/modules | |
parent | aaabf27f44960be687688cf814a08a0ab032fadc (diff) |
m_spanningtree UID handler: Log and drop the link when a server introduces a user with an unknown user mode
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_spanningtree/uid.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index 8a74e2f93..8e4c631f2 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -107,31 +107,33 @@ CmdResult CommandUID::Handle(const parameterlist ¶ms, User* serversrc) std::string::size_type pos = modestr.find_first_not_of('+'); for (std::string::const_iterator v = modestr.begin()+pos; v != modestr.end(); ++v) { - /* For each mode thats set, increase counter */ + /* For each mode thats set, find the mode handler and set it on the new user */ ModeHandler* mh = ServerInstance->Modes->FindMode(*v, MODETYPE_USER); + if (!mh) + { + ServerInstance->Logs->Log("m_spanningtree", LOG_DEFAULT, "Unrecognised mode '%c' for a user in UID, dropping link", *v); + return CMD_INVALID; + } - if (mh) + if (mh->GetNumParams(true)) { - if (mh->GetNumParams(true)) - { - if (paramptr >= params.size() - 1) - return CMD_INVALID; - std::string mp = params[paramptr++]; - /* IMPORTANT NOTE: - * All modes are assumed to succeed here as they are being set by a remote server. - * Modes CANNOT FAIL here. If they DO fail, then the failure is ignored. This is important - * to note as all but one modules currently cannot ever fail in this situation, except for - * m_servprotect which specifically works this way to prevent the mode being set ANYWHERE - * but here, at client introduction. You may safely assume this behaviour is standard and - * will not change in future versions if you want to make use of this protective behaviour - * yourself. - */ - mh->OnModeChange(_new, _new, NULL, mp, true); - } - else - mh->OnModeChange(_new, _new, NULL, empty, true); - _new->SetMode(*v, true); + if (paramptr >= params.size() - 1) + return CMD_INVALID; + std::string mp = params[paramptr++]; + /* IMPORTANT NOTE: + * All modes are assumed to succeed here as they are being set by a remote server. + * Modes CANNOT FAIL here. If they DO fail, then the failure is ignored. This is important + * to note as all but one modules currently cannot ever fail in this situation, except for + * m_servprotect which specifically works this way to prevent the mode being set ANYWHERE + * but here, at client introduction. You may safely assume this behaviour is standard and + * will not change in future versions if you want to make use of this protective behaviour + * yourself. + */ + mh->OnModeChange(_new, _new, NULL, mp, true); } + else + mh->OnModeChange(_new, _new, NULL, empty, true); + _new->SetMode(*v, true); } _new->SetClientIP(params[6].c_str()); |