mirror of https://github.com/Icinga/icinga2.git
Merge pull request #10077 from RincewindsHat/reject_invalid_perfdata
Reject infinite performance data values
This commit is contained in:
commit
55829c4f55
|
@ -259,6 +259,10 @@ PerfdataValue::Ptr PerfdataValue::Parse(const String& perfdata)
|
|||
|
||||
double value = Convert::ToDouble(tokens[0].SubStr(0, pos));
|
||||
|
||||
if (!std::isfinite(value)) {
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid performance data value: " + perfdata + " is outside of any reasonable range"));
|
||||
}
|
||||
|
||||
bool counter = false;
|
||||
String unit;
|
||||
Value warn, crit, min, max;
|
||||
|
|
|
@ -336,6 +336,10 @@ BOOST_AUTO_TEST_CASE(invalid)
|
|||
BOOST_CHECK_THROW(PerfdataValue::Parse("test=1;1;123,456;1;1"), boost::exception);
|
||||
BOOST_CHECK_THROW(PerfdataValue::Parse("test=1;1;1;123,456;1"), boost::exception);
|
||||
BOOST_CHECK_THROW(PerfdataValue::Parse("test=1;1;1;1;123,456"), boost::exception);
|
||||
BOOST_CHECK_THROW(PerfdataValue::Parse("test=inf"), boost::exception);
|
||||
BOOST_CHECK_THROW(PerfdataValue::Parse("test=Inf"), boost::exception);
|
||||
BOOST_CHECK_THROW(PerfdataValue::Parse("test=-inf"), boost::exception);
|
||||
BOOST_CHECK_THROW(PerfdataValue::Parse("test=-Inf"), boost::exception);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(multi)
|
||||
|
|
Loading…
Reference in New Issue