From 86f650e6b8c969b31fae65ea1143644723279b82 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Wed, 10 Jul 2013 14:28:05 +0100 Subject: Replace range() with min and max arguments on getInt(). --- src/configparser.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/configparser.cpp') diff --git a/src/configparser.cpp b/src/configparser.cpp index 3289cf396..f3e79e2fd 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -420,7 +420,7 @@ std::string ConfigTag::getString(const std::string& key, const std::string& def) return res; } -long ConfigTag::getInt(const std::string &key, long def) +long ConfigTag::getInt(const std::string &key, long def, long min, long max) { std::string result; if(!readString(key, result)) @@ -434,15 +434,21 @@ long ConfigTag::getInt(const std::string &key, long def) switch (toupper(*res_tail)) { case 'K': - res= res* 1024; + res = res * 1024; break; case 'M': - res= res* 1024 * 1024; + res = res * 1024 * 1024; break; case 'G': - res= res* 1024 * 1024 * 1024; + res = res * 1024 * 1024 * 1024; break; } + if (res < min || res > max) + { + ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "WARNING: <%s:%s> value of %ld is not between %ld and %ld; set to %ld.", + tag.c_str(), key.c_str(), res, min, max, def); + res = def; + } return res; } -- cgit v1.3.1-10-gc9f91