[monitoring-plugins] check_ntp_peer: do not use uninitialized results ...

Sven Nierlein git at monitoring-plugins.org
Thu Jul 31 11:40:07 CEST 2014


 Module: monitoring-plugins
 Branch: master
 Commit: df08974bf07bae1ea5dcbec68bad4cdfce52aeff
 Author: Sven Nierlein <sven at nierlein.de>
   Date: Thu Jul 31 11:28:30 2014 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=df08974

check_ntp_peer: do not use uninitialized results for max state

s/t/jresult are not initialized if there is no corresponding threshold
supplied. So we shouldn't use them for calculating our result.

Signed-off-by: Sven Nierlein <sven at nierlein.de>

---

 plugins/check_ntp_peer.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c
index d3ae599..44424af 100644
--- a/plugins/check_ntp_peer.c
+++ b/plugins/check_ntp_peer.c
@@ -599,17 +599,20 @@ int main(int argc, char *argv[]){
 	}
 	oresult = result;
 	
-	if(do_truechimers)
+	if(do_truechimers) {
 		tresult = get_status(num_truechimers, truechimer_thresholds);
 		result = max_state_alt(result, tresult);
+	}
 
-	if(do_stratum)
+	if(do_stratum) {
 		sresult = get_status(stratum, stratum_thresholds);
 		result = max_state_alt(result, sresult);
+	}
 
-	if(do_jitter)
+	if(do_jitter) {
 		jresult = get_status(jitter, jitter_thresholds);
 		result = max_state_alt(result, jresult);
+	}
 
 	switch (result) {
 		case STATE_CRITICAL :



More information about the Commits mailing list