From f75a0d5482a09fffc0cc6cfece80bb2f1e4de815 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sun, 19 Jan 2014 16:48:41 +0100 Subject: Use FindNickOnly() in a few more places if a local user is performing an action to prevent UID walking --- src/mode.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/mode.cpp') 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& 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(); -- cgit v1.2.3