From b79a9a1221b35a03aec3b949a32d97d2e2ce66af Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Wed, 4 Jul 2012 21:36:49 +0200 Subject: m_spanningtree FTOPIC handler: Return CMD_FAILURE/CMD_INVALID as appropiate Return CMD_FAILURE to prevent propagation when the topic wasn't updated; return CMD_INVALID when the topicts is invalid --- src/modules/m_spanningtree/ftopic.cpp | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'src/modules/m_spanningtree') diff --git a/src/modules/m_spanningtree/ftopic.cpp b/src/modules/m_spanningtree/ftopic.cpp index 4e57715f3..3094b38e1 100644 --- a/src/modules/m_spanningtree/ftopic.cpp +++ b/src/modules/m_spanningtree/ftopic.cpp @@ -28,24 +28,29 @@ /** FTOPIC command */ CmdResult CommandFTopic::Handle(const std::vector& params, User *user) { - time_t ts = ConvToInt(params[1]); Channel* c = ServerInstance->FindChan(params[0]); - if (c) + if (!c) + return CMD_FAILURE; + + time_t ts = ConvToInt(params[1]); + if (!ts) + return CMD_INVALID; + + // Channel::topicset is initialized to 0 on channel creation, so their ts will always win if we never had a topic + if (ts < c->topicset) + return CMD_FAILURE; + + if (c->topic != params[3]) { - if ((ts >= c->topicset) || (c->topic.empty())) - { - if (c->topic != params[3]) - { - // Update topic only when it differs from current topic - c->topic.assign(params[3], 0, ServerInstance->Config->Limits.MaxTopic); - c->WriteChannel(user, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str()); - } - - // Always update setter and settime. - c->setby.assign(params[2], 0, 127); - c->topicset = ts; - } + // Update topic only when it differs from current topic + c->topic.assign(params[3], 0, ServerInstance->Config->Limits.MaxTopic); + c->WriteChannel(user, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str()); } + + // Always update setter and settime. + c->setby.assign(params[2], 0, 127); + c->topicset = ts; + return CMD_SUCCESS; } -- cgit v1.2.3