summaryrefslogtreecommitdiff
path: root/src/config.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-07-21 03:59:59 -0400
committerAdam <Adam@anope.org>2013-07-21 03:59:59 -0400
commit604da898136b9299f555336df633e30a09f44ddd (patch)
treeab4a3e380d16a6f9b6e2f320feaaeb095ff2c872 /src/config.cpp
parente11abdc4f00b19feae7830d4de6098e282e7eb39 (diff)
More basic config validation, and fix crash when no uplinks are configured. spotted by fgs
Diffstat (limited to 'src/config.cpp')
-rw-r--r--src/config.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/config.cpp b/src/config.cpp
index 8ba56bda2..1000e6cf4 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -106,6 +106,12 @@ static void ValidateNotEmpty(const Anope::string &block, const Anope::string &na
throw ConfigException("The value for <" + block + ":" + name + "> cannot be empty!");
}
+static void ValidateNoSpaces(const Anope::string &block, const Anope::string &name, const Anope::string &value)
+{
+ if (value.find(' ') != Anope::string::npos)
+ throw ConfigException("The value for <" + block + ":" + name + "> may not contain spaces!");
+}
+
template<typename T> static void ValidateNotZero(const Anope::string &block, const Anope::string &name, T value)
{
if (!value)
@@ -158,14 +164,18 @@ Conf::Conf() : Block("")
throw ConfigException("<" + noreload[i].block + ":" + noreload[i].name + "> can not be modified once set");
}
- Block *options = this->GetBlock("options"), *mail = this->GetBlock("mail");
+ Block *serverinfo = this->GetBlock("serverinfo"), *options = this->GetBlock("options"), *mail = this->GetBlock("mail");
+
+ ValidateNotEmpty("serverinfo", "name", serverinfo->Get<const Anope::string>("name"));
+ ValidateNotEmpty("serverinfo", "description", serverinfo->Get<const Anope::string>("description"));
+ ValidateNotEmpty("serverinfo", "pid", serverinfo->Get<const Anope::string>("pid"));
+ ValidateNotEmpty("serverinfo", "motd", serverinfo->Get<const Anope::string>("motd"));
ValidateNotZero("options", "releasetimeout", options->Get<time_t>("releasetimeout"));
ValidateNotZero("options", "updatetimeout", options->Get<time_t>("updatetimeout"));
ValidateNotZero("options", "expiretimeout", options->Get<time_t>("expiretimeout"));
ValidateNotZero("options", "readtimeout", options->Get<time_t>("readtimeout"));
ValidateNotZero("options", "warningtimeout", options->Get<time_t>("warningtimeout"));
- ValidateNotZero("options", "timeoutcheck", options->Get<time_t>("timeoutcheck"));
ValidateNotEmpty("options", "enforceruser", options->Get<const Anope::string>("enforceruser"));
ValidateNotEmpty("options", "enforcerhost", options->Get<const Anope::string>("enforcerhost"));
@@ -313,6 +323,7 @@ Conf::Conf() : Block("")
ValidateNotEmpty("service", "user", user);
ValidateNotEmpty("service", "host", host);
ValidateNotEmpty("service", "gecos", gecos);
+ ValidateNoSpaces("service", "channels", channels);
BotInfo *bi = BotInfo::Find(nick, true);
if (!bi)