Merge pull request #10077 from RincewindsHat/reject_invalid_perfdata

Reject infinite performance data values
This commit is contained in:
Julian Brost 2025-01-13 12:00:12 +01:00 committed by GitHub
commit 55829c4f55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -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;

View File

@ -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)