From 4a12fc9d4bfb77fc2fc05c1052c66294e3774649 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 22 Jul 2016 11:26:11 +0100 Subject: [PATCH] Add a method which calculates the maximum mask length. (#1171) --- include/configreader.h | 3 +++ src/channels.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/configreader.h b/include/configreader.h index fe1e5da9e..f2ba16902 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -121,6 +121,9 @@ class ServerLimits * @param tag Configuration tag to read the limits from */ ServerLimits(ConfigTag* tag); + + /** Maximum length of a n!u@h mask */ + size_t GetMaxMask() const { return NickMax + 1 + IdentMax + 1 + MaxHost; } }; struct CommandLineConf diff --git a/src/channels.cpp b/src/channels.cpp index 30bddec5c..7f2485a49 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -58,7 +58,7 @@ void Channel::SetTopic(User* u, const std::string& ntopic, time_t topicts, const // Always update setter and set time if (!setter) setter = ServerInstance->Config->FullHostInTopic ? &u->GetFullHost() : &u->nick; - this->setby.assign(*setter, 0, 128); + this->setby.assign(*setter, 0, ServerInstance->Config->Limits.GetMaxMask()); this->topicset = topicts; FOREACH_MOD(OnPostTopicChange, (u, this, this->topic)); -- 2.39.5