From 297c720daecb7622f5eee80359987f416fa82227 Mon Sep 17 00:00:00 2001 From: special Date: Sat, 7 Jul 2007 19:58:16 +0000 Subject: Added some missing parameter checking in m_swhois git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7429 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_swhois.cpp | 73 +++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp index 1bde710ac..d635654a5 100644 --- a/src/modules/m_swhois.cpp +++ b/src/modules/m_swhois.cpp @@ -33,45 +33,54 @@ class cmd_swhois : public command_t CmdResult Handle(const char** parameters, int pcnt, userrec* user) { userrec* dest = ServerInstance->FindNick(parameters[0]); - if(dest) + + if (!dest) { - std::string line; - for(int i = 1; i < pcnt; i++) - { - if (i != 1) - line.append(" "); - - line.append(parameters[i]); - } - - std::string* text; - dest->GetExt("swhois", text); - - if(text) - { - // We already had it set... - - if (!ServerInstance->ULine(user->server)) - // Ulines set SWHOISes silently - ServerInstance->WriteOpers("*** %s used SWHOIS to set %s's extra whois from '%s' to '%s'", user->nick, dest->nick, text->c_str(), line.c_str()); + user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]); + return CMD_FAILURE; + } + + if (!*parameters[1]) + { + user->WriteServ("NOTICE %s :*** SWHOIS: Whois line must be specified", user->nick); + return CMD_FAILURE; + } + + std::string line; + for (int i = 1; i < pcnt; i++) + { + if (i != 1) + line.append(" "); - dest->Shrink("swhois"); - DELETE(text); - } - else if(!ServerInstance->ULine(user->server)) - { + line.append(parameters[i]); + } + + std::string* text; + dest->GetExt("swhois", text); + + if (text) + { + // We already had it set... + + if (!ServerInstance->ULine(user->server)) // Ulines set SWHOISes silently - ServerInstance->WriteOpers("*** %s used SWHOIS to set %s's extra whois to '%s'", user->nick, dest->nick, line.c_str()); - } + ServerInstance->WriteOpers("*** %s used SWHOIS to set %s's extra whois from '%s' to '%s'", user->nick, dest->nick, text->c_str(), line.c_str()); - text = new std::string(line); - dest->Extend("swhois", text); - - return CMD_SUCCESS; + dest->Shrink("swhois"); + DELETE(text); + } + else if (!ServerInstance->ULine(user->server)) + { + // Ulines set SWHOISes silently + ServerInstance->WriteOpers("*** %s used SWHOIS to set %s's extra whois to '%s'", user->nick, dest->nick, line.c_str()); } + + text = new std::string(line); + dest->Extend("swhois", text); - return CMD_FAILURE; + return CMD_SUCCESS; } + }; class ModuleSWhois : public Module -- cgit v1.2.3