summaryrefslogtreecommitdiffstats
path: root/plugins/check_ntp.c
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 /plugins/check_ntp.c
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
Diffstat (limited to 'plugins/check_ntp.c')
-rw-r--r--plugins/check_ntp.c21
1 files changed, 14 insertions, 7 deletions
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}