From: Attila Molnar Date: Wed, 6 Aug 2014 11:20:00 +0000 (+0200) Subject: m_exemptchanops Fix parameter validation X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=0b1c84c54185545b62673ad098fe0d3d19c22570;p=user%2Fhenk%2Fcode%2Finspircd.git m_exemptchanops Fix parameter validation --- diff --git a/src/modules/m_exemptchanops.cpp b/src/modules/m_exemptchanops.cpp index 43ae21a1c..2d06b73a0 100644 --- a/src/modules/m_exemptchanops.cpp +++ b/src/modules/m_exemptchanops.cpp @@ -29,9 +29,23 @@ class ExemptChanOps : public ListModeBase bool ValidateParam(User* user, Channel* chan, std::string &word) { - if (!ServerInstance->Modes->FindMode(word, MODETYPE_CHANNEL)) + std::string::size_type p = word.find(':'); + if (p == std::string::npos) { - user->WriteNumeric(955, "%s %s :Mode doesn't exist", chan->name.c_str(), word.c_str()); + user->WriteNumeric(955, "%s %s :Invalid exemptchanops entry, format is :", chan->name.c_str(), word.c_str()); + return false; + } + + std::string restriction = word.substr(0, p); + // If there is a '-' in the restriction string ignore it and everything after it + // to support "auditorium-vis" and "auditorium-see" in m_auditorium + p = restriction.find('-'); + if (p != std::string::npos) + restriction.erase(p); + + if (!ServerInstance->Modes->FindMode(restriction, MODETYPE_CHANNEL)) + { + user->WriteNumeric(955, "%s %s :Unknown restriction", chan->name.c_str(), restriction.c_str()); return false; }