From 0b1c84c54185545b62673ad098fe0d3d19c22570 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 6 Aug 2014 13:20:00 +0200 Subject: m_exemptchanops Fix parameter validation --- src/modules/m_exemptchanops.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3