From 3eb205218a321e454d873ae14e2e717ce9d64142 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 16 Apr 2014 13:08:44 +0200 Subject: m_spanningtree Throw an exception on protocol violations instead of returning CMD_INVALID Catch CoreExceptions, log and close the link in OnDataReady() --- src/modules/m_spanningtree/uid.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'src/modules/m_spanningtree/uid.cpp') diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index 79bd6936f..206f79a48 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -38,14 +38,14 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vectorGetID()) - return CMD_INVALID; + throw ProtocolException("Bogus UUID"); /* Check parameters for validity before introducing the client, discovered by dmb */ if (!age_t) return CMD_INVALID; if (!signon) return CMD_INVALID; if (modestr[0] != '+') - return CMD_INVALID; + throw ProtocolException("Invalid mode string"); /* check for collision */ User* collideswith = ServerInstance->FindNickOnly(params[2]); @@ -66,17 +66,10 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vectorLogs->Log(MODNAME, LOG_DEFAULT, "Duplicate UUID %s in client introduction", params[0].c_str()); - return CMD_INVALID; - } + RemoteUser* _new = new RemoteUser(params[0], remoteserver); ServerInstance->Users->clientlist[params[2]] = _new; _new->nick = params[2]; _new->host = params[3]; @@ -98,15 +91,12 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vectorModes->FindMode(*v, MODETYPE_USER); if (!mh) - { - ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Unrecognised mode '%c' for a user in UID, dropping link", *v); - return CMD_INVALID; - } + throw ProtocolException("Unrecognised mode '" + std::string(1, *v) + "'"); if (mh->GetNumParams(true)) { if (paramptr >= params.size() - 1) - return CMD_INVALID; + throw ProtocolException("Out of parameters while processing modes"); std::string mp = params[paramptr++]; /* IMPORTANT NOTE: * All modes are assumed to succeed here as they are being set by a remote server. -- cgit v1.3.1-10-gc9f91