summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorspecial <special@e03df62e-2008-0410-955e-edbf42e46eb7>2007-07-07 19:58:16 +0000
committerspecial <special@e03df62e-2008-0410-955e-edbf42e46eb7>2007-07-07 19:58:16 +0000
commit297c720daecb7622f5eee80359987f416fa82227 (patch)
tree08b10733e44eed067aa48ae4a55df1eb3f6080da /src
parenta53da00bce41c9fb50ed4c9d33507f27803c1eb7 (diff)
Added some missing parameter checking in m_swhois
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7429 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_swhois.cpp73
1 files 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