summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-07-18 16:52:14 -0400
committerAdam <Adam@anope.org>2012-07-18 16:52:14 -0400
commit48022c3ddfaa162f546c8fd7235586a2c7f36fc8 (patch)
treee838e7fb52301336031bea85400353b7787178a9
parent28aa981464dc5834a04f52314c798adab260c5a4 (diff)
Warn about really big integer values in the config
-rw-r--r--modules/commands/os_set.cpp2
-rw-r--r--src/config.cpp11
2 files changed, 11 insertions, 2 deletions
diff --git a/modules/commands/os_set.cpp b/modules/commands/os_set.cpp
index 9ecae3105..a8a7e2e62 100644
--- a/modules/commands/os_set.cpp
+++ b/modules/commands/os_set.cpp
@@ -114,7 +114,7 @@ class CommandOSSet : public Command
Log(LOG_ADMIN, source, this) << "DEBUG ON";
source.Reply(_("Services are now in debug mode."));
}
- else if (setting.equals_ci("OFF") || (setting[0] == '0' && setting.is_number_only() && !convertTo<int>(setting)))
+ else if (setting.equals_ci("OFF") || setting == "0")
{
Log(LOG_ADMIN, source, this) << "DEBUG OFF";
debug = 0;
diff --git a/src/config.cpp b/src/config.cpp
index 0c5d1c2af..2c0e264f2 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -1941,7 +1941,16 @@ int ValueItem::GetInteger() const
{
if (v.empty() || !v.is_number_only())
return 0;
- return convertTo<int>(v);
+ try
+ {
+ return convertTo<int>(v);
+ }
+ catch (const ConvertException &)
+ {
+ Log() << "Unable to convert configuration value " << this->v << " to an integer. Value too large?";
+ }
+
+ return 0;
}
const char *ValueItem::GetString() const