From 4dfcdc1734194e68faaf64ebe910da23e6b80b28 Mon Sep 17 00:00:00 2001 From: danieldg Date: Thu, 19 Feb 2009 18:02:46 +0000 Subject: Fix crash on /SHUN with exactly 2 parameters git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11131 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_shun.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index c007228e3..09d9872ad 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -114,12 +114,23 @@ class CommandShun : public Command else if (parameters.size() >= 2) { // Adding - XXX todo make this respect tag perhaps.. - long duration = ServerInstance->Duration(parameters[1]); + long duration; + std::string expr; + if (parameters.size() > 2) + { + duration = ServerInstance->Duration(parameters[1]); + expr = parameters[2]; + } + else + { + duration = 0; + expr = parameters[1]; + } Shun *r = NULL; try { - r = new Shun(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str()); + r = new Shun(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), expr.c_str(), parameters[0].c_str()); } catch (...) { @@ -132,12 +143,14 @@ class CommandShun : public Command { if (!duration) { - ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent shun for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str()); + ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent shun for %s: %s", + user->nick.c_str(), parameters[0].c_str(), expr.c_str()); } else { time_t c_requires_crap = duration + ServerInstance->Time(); - ServerInstance->SNO->WriteToSnoMask('x', "%s added timed shun for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str()); + ServerInstance->SNO->WriteToSnoMask('x', "%s added timed shun for %s, expires on %s: %s", + user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), expr.c_str()); } ServerInstance->XLines->ApplyLines(); @@ -145,7 +158,7 @@ class CommandShun : public Command else { delete r; - user->WriteServ("NOTICE %s :*** Shun for %s already exists", user->nick.c_str(), parameters[0].c_str()); + user->WriteServ("NOTICE %s :*** Shun for %s already exists", user->nick.c_str(), expr.c_str()); } } } -- cgit v1.2.3