From 80e80132826569444e690a177f5bfc5f603fada1 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 17 Apr 2022 11:02:42 +0100 Subject: Remove ValidateParam and rename CanonicalizeParam. There's basically no safe way to handle a malformed list mode sent by a remote server without causing a desync. Its probably for the best if we just only apply validation to locally added list modes entries. --- src/listmode.cpp | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'src/listmode.cpp') diff --git a/src/listmode.cpp b/src/listmode.cpp index e224f1168..6ba6d1771 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -157,7 +157,7 @@ ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, Mod { // Try to canonicalise the parameter locally. LocalUser* lsource = IS_LOCAL(source); - if (lsource && !CanonicalizeParam(lsource, channel, change.param)) + if (lsource && !ValidateParam(lsource, channel, change.param)) return MODEACTION_DENY; // If there was no list @@ -188,27 +188,8 @@ ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, Mod return MODEACTION_DENY; } - /* Ok, it *could* be allowed, now give someone subclassing us - * a chance to validate the parameter. - * The param is passed by reference, so they can both modify it - * and tell us if we allow it or not. - * - * eg, the subclass could: - * 1) allow - * 2) 'fix' parameter and then allow - * 3) deny - */ - if (ValidateParam(source, channel, change.param)) - { - // And now add the mask onto the list... - cd->list.emplace_back(change.param, change.set_by.value_or(source->nick), change.set_at.value_or(ServerInstance->Time())); - return MODEACTION_ALLOW; - } - else - { - /* If they deny it they have the job of giving an error message */ - return MODEACTION_DENY; - } + cd->list.emplace_back(change.param, change.set_by.value_or(source->nick), change.set_at.value_or(ServerInstance->Time())); + return MODEACTION_ALLOW; } else { @@ -231,12 +212,7 @@ ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, Mod } } -bool ListModeBase::CanonicalizeParam(LocalUser* user, Channel* channel, std::string& parameter) -{ - return true; -} - -bool ListModeBase::ValidateParam(User* user, Channel* channel, const std::string& parameter) +bool ListModeBase::ValidateParam(LocalUser* user, Channel* channel, std::string& parameter) { return true; } -- cgit v1.3.1-10-gc9f91