summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2008-01-05 14:09:29 (GMT)
committerThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2008-01-05 14:09:29 (GMT)
commitb5d3997aa39169637871a4bca5f860fae21aba3e (patch)
tree4c6b9e0ac14a45406db2c83a36049e0ea420c4eb
parentf83981580eced39b10e096b8eb9a6c4e6434e772 (diff)
downloadmonitoring-plugins-b5d3997aa39169637871a4bca5f860fae21aba3e.tar.gz
Fix Bug #1862300: check_ntp_time segfault in 1.4.11 (Also apply to check_ntp)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1887 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--NEWS1
-rw-r--r--plugins/check_ntp.c21
-rw-r--r--plugins/check_ntp_time.c3
3 files changed, 17 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index 485693a..a58c4ce 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ This file documents the major additions and syntax changes between releases.
5 check_tcp now returns UNKNOWN with invalid hostname 5 check_tcp now returns UNKNOWN with invalid hostname
6 New check_icmp -s option to specify the source IP address 6 New check_icmp -s option to specify the source IP address
7 check_dns now sorts addresses for testing results for more than one returned IP (Matthias Urlichs) 7 check_dns now sorts addresses for testing results for more than one returned IP (Matthias Urlichs)
8 Fix segfault in check_ntp_time and (deprecated) check_ntp. (Bug #1862300)
8 9
91.4.11 13th December 2007 101.4.11 13th December 2007
10 Fixed check_http regression in 1.4.10 where following redirects to 11 Fixed check_http regression in 1.4.10 where following redirects to
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 86e3d09..b474d9a 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -329,7 +329,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){
329 /* if we haven't reached the current list's end, move everyone 329 /* if we haven't reached the current list's end, move everyone
330 * over one to the right, and insert the new candidate */ 330 * over one to the right, and insert the new candidate */
331 if(i<csize){ 331 if(i<csize){
332 for(j=5; j>i; j--){ 332 for(j=4; j>i; j--){
333 candidates[j]=candidates[j-1]; 333 candidates[j]=candidates[j-1];
334 } 334 }
335 } 335 }
@@ -392,6 +392,7 @@ double offset_request(const char *host, int *status){
392 servers=(ntp_server_results*)malloc(sizeof(ntp_server_results)*num_hosts); 392 servers=(ntp_server_results*)malloc(sizeof(ntp_server_results)*num_hosts);
393 if(servers==NULL) die(STATE_UNKNOWN, "can not allocate server array"); 393 if(servers==NULL) die(STATE_UNKNOWN, "can not allocate server array");
394 memset(servers, 0, sizeof(ntp_server_results)*num_hosts); 394 memset(servers, 0, sizeof(ntp_server_results)*num_hosts);
395 DBG(printf("Found %d peers to check\n", num_hosts));
395 396
396 /* setup each socket for writing, and the corresponding struct pollfd */ 397 /* setup each socket for writing, and the corresponding struct pollfd */
397 ai_tmp=ai; 398 ai_tmp=ai;
@@ -837,11 +838,11 @@ void print_help(void){
837 838
838 printf ("Copyright (c) 2006 Sean Finney\n"); 839 printf ("Copyright (c) 2006 Sean Finney\n");
839 printf (COPYRIGHT, copyright, email); 840 printf (COPYRIGHT, copyright, email);
840
841 printf ("%s\n", _("This plugin checks the selected ntp server"));
842 841
843 printf ("\n\n"); 842 printf ("%s\n", _("This plugin checks the selected ntp server"));
844 843
844 printf ("\n\n");
845
845 print_usage(); 846 print_usage();
846 printf (_(UT_HELP_VRSN)); 847 printf (_(UT_HELP_VRSN));
847 printf (_(UT_HOST_PORT), 'p', "123"); 848 printf (_(UT_HOST_PORT), 'p', "123");
@@ -871,11 +872,17 @@ void print_help(void){
871 printf(" %s\n", ("./check_ntp -H ntpserv -w 0.5 -c 1 -j -1:100 -k -1:200")); 872 printf(" %s\n", ("./check_ntp -H ntpserv -w 0.5 -c 1 -j -1:100 -k -1:200"));
872 873
873 printf (_(UT_SUPPORT)); 874 printf (_(UT_SUPPORT));
875
876 printf("\n");
877 printf ("%s\n", _("WARNING: check_ntp is deprecated. Please use check_ntp_peer or"));
878 printf ("%s\n\n", _("check_ntp_time istead."));
874} 879}
875 880
876void 881void
877print_usage(void) 882print_usage(void)
878{ 883{
879 printf (_("Usage:")); 884 printf ("%s\n", _("WARNING: check_ntp is deprecated. Please use check_ntp_peer or"));
880 printf(" %s -H <host> [-w <warn>] [-c <crit>] [-j <warn>] [-k <crit>] [-v verbose]\n", progname); 885 printf ("%s\n\n", _("check_ntp_time istead."));
886 printf (_("Usage:"));
887 printf(" %s -H <host> [-w <warn>] [-c <crit>] [-j <warn>] [-k <crit>] [-v verbose]\n", progname);
881} 888}
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c
index f414c32..767dcd9 100644
--- a/plugins/check_ntp_time.c
+++ b/plugins/check_ntp_time.c
@@ -274,7 +274,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){
274 /* if we haven't reached the current list's end, move everyone 274 /* if we haven't reached the current list's end, move everyone
275 * over one to the right, and insert the new candidate */ 275 * over one to the right, and insert the new candidate */
276 if(i<csize){ 276 if(i<csize){
277 for(j=5; j>i; j--){ 277 for(j=4; j>i; j--){
278 candidates[j]=candidates[j-1]; 278 candidates[j]=candidates[j-1];
279 } 279 }
280 } 280 }
@@ -337,6 +337,7 @@ double offset_request(const char *host, int *status){
337 servers=(ntp_server_results*)malloc(sizeof(ntp_server_results)*num_hosts); 337 servers=(ntp_server_results*)malloc(sizeof(ntp_server_results)*num_hosts);
338 if(servers==NULL) die(STATE_UNKNOWN, "can not allocate server array"); 338 if(servers==NULL) die(STATE_UNKNOWN, "can not allocate server array");
339 memset(servers, 0, sizeof(ntp_server_results)*num_hosts); 339 memset(servers, 0, sizeof(ntp_server_results)*num_hosts);
340 DBG(printf("Found %d peers to check\n", num_hosts));
340 341
341 /* setup each socket for writing, and the corresponding struct pollfd */ 342 /* setup each socket for writing, and the corresponding struct pollfd */
342 ai_tmp=ai; 343 ai_tmp=ai;