From e4694e467513a7d4d298e55027e58bf9a7917958 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 11 Nov 2006 12:15:11 +0000 Subject: Oops, add special-case for user killing themselves (their userrec is gone when the function returns) Also put checks in LoopCall to check that the user didnt vanish half way through the comma seperated list, if they did, abort at that element of the list. This means if your nick is 'a' and you do "/kill b,c,a,f,g die" only you, b and c will be removed from irc. (this is to be expected, really) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5684 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/cmd_kill.cpp | 3 +++ src/command_parse.cpp | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/cmd_kill.cpp b/src/cmd_kill.cpp index fb5dba245..e2a8d8824 100644 --- a/src/cmd_kill.cpp +++ b/src/cmd_kill.cpp @@ -88,6 +88,9 @@ CmdResult cmd_kill::Handle (const char** parameters, int pcnt, userrec *user) ServerInstance->SNO->WriteToSnoMask('k',"Local Kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]); snprintf(killreason,MAXQUIT,"Killed (%s (%s))", user->nick, parameters[1]); userrec::QuitUser(ServerInstance, u, killreason); + + if (u == user) + return CMD_USER_DELETED; } } else diff --git a/src/command_parse.cpp b/src/command_parse.cpp index b67b269d2..0abfc5b04 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -241,7 +241,8 @@ int CommandParser::LoopCall(userrec* user, command_t* CommandObj, const char** p new_parameters[splithere] = item.c_str(); new_parameters[extra] = extrastuff.c_str(); - CommandObj->Handle(new_parameters,pcnt,user); + if (CommandObj->Handle(new_parameters,pcnt,user) == CMD_USER_DELETED) + return 1; dupes[item.c_str()] = true; } @@ -281,7 +282,13 @@ int CommandParser::LoopCall(userrec* user, command_t* CommandObj, const char** p new_parameters[splithere] = item.c_str(); parameters[splithere] = item.c_str(); - CommandObj->Handle(new_parameters,pcnt,user); + + /* Execute the command handler over and over. If someone pulls our user + * record out from under us (e.g. if we /kill a comma sep list, and we're + * in that list ourselves) abort if we're gone. + */ + if (CommandObj->Handle(new_parameters,pcnt,user) == CMD_USER_DELETED) + return 1; dupes[item.c_str()] = true; } -- cgit v1.2.3