summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/configparser.cpp14
-rw-r--r--src/modules/m_alias.cpp3
-rw-r--r--src/modules/m_operprefix.cpp3
3 files changed, 13 insertions, 7 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp
index 7c03fe58a..86268a132 100644
--- a/src/configparser.cpp
+++ b/src/configparser.cpp
@@ -402,10 +402,18 @@ bool ConfigTag::readString(const std::string& key, std::string& value, bool allo
return false;
}
-std::string ConfigTag::getString(const std::string& key, const std::string& def)
+std::string ConfigTag::getString(const std::string& key, const std::string& def, size_t minlen, size_t maxlen)
{
- std::string res = def;
- readString(key, res);
+ std::string res;
+ if (!readString(key, res))
+ return def;
+
+ if (res.length() < minlen || res.length() > maxlen)
+ {
+ ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "WARNING: The length of <%s:%s> is not between %ld and %ld; value set to %s.",
+ tag.c_str(), key.c_str(), minlen, maxlen, def.c_str());
+ return def;
+ }
return res;
}
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index 6d8e3a1c6..95667e7ed 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -73,8 +73,7 @@ class ModuleAlias : public Module
{
ConfigTag* fantasy = ServerInstance->Config->ConfValue("fantasy");
AllowBots = fantasy->getBool("allowbots", false);
- std::string fpre = fantasy->getString("prefix");
- fprefix = fpre.empty() ? "!" : fpre;
+ fprefix = fantasy->getString("prefix", "!", 1, ServerInstance->Config->Limits.MaxLine);
Aliases.clear();
ConfigTagList tags = ServerInstance->Config->ConfTags("alias");
diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp
index b355047ee..73155b394 100644
--- a/src/modules/m_operprefix.cpp
+++ b/src/modules/m_operprefix.cpp
@@ -32,8 +32,7 @@ class OperPrefixMode : public PrefixMode
OperPrefixMode(Module* Creator)
: PrefixMode(Creator, "operprefix", 'y', OPERPREFIX_VALUE)
{
- std::string pfx = ServerInstance->Config->ConfValue("operprefix")->getString("prefix", "!");
- prefix = pfx.empty() ? '!' : pfx[0];
+ prefix = ServerInstance->Config->ConfValue("operprefix")->getString("prefix", "!", 1, 1)[0];
levelrequired = INT_MAX;
}
};