summaryrefslogtreecommitdiff
path: root/src/mode.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-01-19 16:48:41 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-01-19 16:48:41 +0100
commitf75a0d5482a09fffc0cc6cfece80bb2f1e4de815 (patch)
treee2031e58b6166c7690e1968be21f2294a4e81ef1 /src/mode.cpp
parent69af56f973b9d31f5ebd7d83e6afedb59bb08c92 (diff)
Use FindNickOnly() in a few more places if a local user is performing an action to prevent UID walking
Diffstat (limited to 'src/mode.cpp')
-rw-r--r--src/mode.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index 16751e712..2a32dfac2 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -346,10 +346,19 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool
return MODEACTION_DENY;
}
- if (mh->GetTranslateType() == TR_NICK && !ServerInstance->FindNick(parameter))
+ if (mh->GetTranslateType() == TR_NICK)
{
- user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameter.c_str());
- return MODEACTION_DENY;
+ User* prefixtarget;
+ if (IS_LOCAL(user))
+ prefixtarget = ServerInstance->FindNickOnly(parameter);
+ else
+ prefixtarget = ServerInstance->FindNick(parameter);
+
+ if (!prefixtarget)
+ {
+ user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameter.c_str());
+ return MODEACTION_DENY;
+ }
}
if (mh->GetPrefixRank() && chan)
@@ -378,9 +387,16 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool
void ModeParser::Process(const std::vector<std::string>& parameters, User *user, bool merge)
{
- std::string target = parameters[0];
+ const std::string& target = parameters[0];
Channel* targetchannel = ServerInstance->FindChan(target);
- User* targetuser = ServerInstance->FindNick(target);
+ User* targetuser = NULL;
+ if (!targetchannel)
+ {
+ if (IS_LOCAL(user))
+ targetuser = ServerInstance->FindNickOnly(target);
+ else
+ targetuser = ServerInstance->FindNick(target);
+ }
ModeType type = targetchannel ? MODETYPE_CHANNEL : MODETYPE_USER;
LastParse.clear();