summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2018-04-14 16:11:57 +0100
committerPeter Powell <petpow@saberuk.com>2018-04-16 15:29:58 +0100
commit9b8dc77585ada328a306bc12bb9827f083e7cf93 (patch)
tree13f89459bd95cca9fcd23ba2a3cd36e17f85b361 /src
parent780dda83ba3857bc3c330d4b5d38bb251a9d879b (diff)
Add range checking to ConfigTag::getFloat.
Diffstat (limited to 'src')
-rw-r--r--src/configparser.cpp7
-rw-r--r--src/coremods/core_xline/core_xline.cpp2
2 files changed, 6 insertions, 3 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp
index 5ee86c811..8a3042eba 100644
--- a/src/configparser.cpp
+++ b/src/configparser.cpp
@@ -524,12 +524,15 @@ unsigned long ConfigTag::getDuration(const std::string& key, unsigned long def,
return ret;
}
-double ConfigTag::getFloat(const std::string &key, double def)
+double ConfigTag::getFloat(const std::string& key, double def, double min, double max)
{
std::string result;
if (!readString(key, result))
return def;
- return strtod(result.c_str(), NULL);
+
+ double res = strtod(result.c_str(), NULL);
+ CheckRange(tag, key, res, def, min, max);
+ return res;
}
bool ConfigTag::getBool(const std::string &key, bool def)
diff --git a/src/coremods/core_xline/core_xline.cpp b/src/coremods/core_xline/core_xline.cpp
index d6c804748..ab80ab4ed 100644
--- a/src/coremods/core_xline/core_xline.cpp
+++ b/src/coremods/core_xline/core_xline.cpp
@@ -28,7 +28,7 @@ bool InsaneBan::MatchesEveryone(const std::string& mask, MatcherBase& test, User
if (insane->getBool(confkey))
return false;
- float itrigger = insane->getFloat("trigger", 95.5);
+ float itrigger = insane->getFloat("trigger", 95.5, 0.0, 100.0);
long matches = test.Run(mask);