[monitoring-plugins] Fix inclusive upper bound for negative-infinity ...

Lorenz Kästle git at monitoring-plugins.org
Wed Sep 23 17:00:16 CEST 2026


    Module: monitoring-plugins
    Branch: master
    Commit: fe166a0945852eb1236c715c5b1c108341bf8b30
    Author: Devstellar <5107748+Devstellar at users.noreply.github.com>
 Committer: Lorenz Kästle <12514511+RincewindsHat at users.noreply.github.com>
      Date: Fri Sep 18 21:27:21 2026 +0200
       URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=fe166a09

Fix inclusive upper bound for negative-infinity ranges

---

 lib/tests/test_utils.c | 11 ++++++++++-
 lib/utils_base.c       |  2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c
index ce374a4f..d3c5d237 100644
--- a/lib/tests/test_utils.c
+++ b/lib/tests/test_utils.c
@@ -28,7 +28,7 @@
 #include "utils_base.c"
 
 int main(int argc, char **argv) {
-	plan_tests(132);
+	plan_tests(135);
 
 	ok(this_monitoring_plugin == NULL, "monitoring_plugin not initialised");
 
@@ -109,6 +109,15 @@ int main(int argc, char **argv) {
 	ok(check_range(0, range) == false, "0 - no alert");
 	free(range);
 
+	mp_range mp_range_test = mp_range_init();
+	mp_range_test = mp_range_set_end(mp_range_test, mp_create_pd_value(2));
+	ok(mp_check_range(mp_create_pd_value(1), mp_range_test) == false,
+		"mp range ~:2: 1 - no alert");
+	ok(mp_check_range(mp_create_pd_value(2), mp_range_test) == false,
+		"mp range ~:2: 2 - no alert");
+	ok(mp_check_range(mp_create_pd_value(3), mp_range_test) == true,
+		"mp range ~:2: 3 - alert");
+
 	range = parse_range_string("@0:657.8210567");
 	ok(range != 0, "@0:657.8210567' is a valid range");
 	ok(range->start == 0, "Start correct");
diff --git a/lib/utils_base.c b/lib/utils_base.c
index 812bed65..98915f2a 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -228,7 +228,7 @@ bool mp_check_range(const mp_perfdata_value value, const mp_range my_range) {
 	} else if (my_range.start_infinity && !my_range.end_infinity) {
 		// range:  -inside--------|....................
 		// value
-		is_inside = (cmp_perfdata_value(value, my_range.end) == -1);
+		is_inside = (cmp_perfdata_value(value, my_range.end) <= 0);
 	} else {
 		// range from -inf to inf, so always inside
 		is_inside = true;



More information about the Commits mailing list