summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2012-07-04 21:36:49 +0200
committerattilamolnar <attilamolnar@hush.com>2013-04-12 21:03:04 +0200
commitb79a9a1221b35a03aec3b949a32d97d2e2ce66af (patch)
tree5aa95f1a26313cf9404f2ea16db6a4ec595d1a38
parentf4cd5fb72ad191a3708d3d39a4fc74cc1ae4377e (diff)
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
-rw-r--r--src/modules/m_spanningtree/ftopic.cpp35
1 files changed, 20 insertions, 15 deletions
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<std::string>& 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;
}