[monitoring-plugins] check_users: Change option for sanity checking ...

RincewindsHat git at monitoring-plugins.org
Sun Nov 12 02:40:12 CET 2023


 Module: monitoring-plugins
 Branch: master
 Commit: cff821257bebdbfba87d183726ea9672625c2e77
 Author: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com>
   Date: Tue Oct 31 01:47:26 2023 +0100
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=cff8212

check_users: Change option for sanity checking arguments to avoid segfault

---

 plugins/check_users.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/plugins/check_users.c b/plugins/check_users.c
index 7cf7a2c..916a691 100644
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
@@ -227,18 +227,23 @@ process_arguments (int argc, char **argv)
 	}
 
 	c = optind;
+
 	if (warning_range == NULL && argc > c)
 		warning_range = argv[c++];
+
 	if (critical_range == NULL && argc > c)
 		critical_range = argv[c++];
 
 	/* this will abort in case of invalid ranges */
 	set_thresholds (&thlds, warning_range, critical_range);
 
-	if (thlds->warning->end < 0)
-		usage4 (_("Warning threshold must be a positive integer"));
-	if (thlds->critical->end < 0)
-		usage4 (_("Critical threshold must be a positive integer"));
+	if (!thlds->warning) {
+		usage4 (_("Warning threshold must be a valid range expression"));
+	}
+
+	if (!thlds->critical) {
+		usage4 (_("Critical threshold must be a valid range expression"));
+	}
 
 	return OK;
 }



More information about the Commits mailing list