[Nagiosplug-devel] [ nagiosplug-Patches-2993229 ] check_ntp_time: Bug in average calculation

SourceForge.net noreply at sourceforge.net
Tue Apr 27 23:08:10 CEST 2010


Patches item #2993229, was opened at 2010-04-27 23:08
Message generated for change (Tracker Item Submitted) made by larsi-
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397599&aid=2993229&group_id=29880

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Bugfix
Group: release-1.4.14
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: lars (larsi-)
Assigned to: Nobody/Anonymous (nobody)
Summary: check_ntp_time: Bug in average calculation

Initial Comment:
Hello Nagios-Plugins Team,

attached you can find a patch which applies to current check_ntp_time. The bug was found by Mathias Kettner.

The patch contains the following changes:
1. A minor change which makes the AVG_NUM configurable by compiler define.
2. The more important change: A fix for a bug which caused the check_ntp_time check to always take the first response from ntp and not the avarage since "j" is not increased anywhere. "i" should be used there instead.

Kind regards,
Lars

--- check_ntp_time.c.orig	2010-04-27 12:08:08.000000000 +0000
+++ check_ntp_time.c	2010-04-27 12:13:23.000000000 +0000
@@ -55,7 +55,9 @@
 void print_usage (void);
 
 /* number of times to perform each request to get a good average. */
+#ifndef AVG_NUM
 #define AVG_NUM 4
+#endif
 
 /* max size of control message data */
 #define MAX_CM_SIZE 468
@@ -422,7 +424,7 @@
 	} else {
 		/* finally, calculate the average offset */
 		for(i=0; i<servers[best_index].num_responses;i++){
-			avg_offset+=servers[best_index].offset[j];
+			avg_offset+=servers[best_index].offset[i];
 		}
 		avg_offset/=servers[best_index].num_responses;
 	}


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397599&aid=2993229&group_id=29880




More information about the Devel mailing list