From b5d3997aa39169637871a4bca5f860fae21aba3e Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Sat, 5 Jan 2008 14:09:29 +0000 Subject: 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 --- plugins/check_ntp.c | 21 ++++++++++++++------- plugins/check_ntp_time.c | 3 ++- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c index 86e3d098..b474d9a8 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){ /* if we haven't reached the current list's end, move everyone * over one to the right, and insert the new candidate */ if(ii; j--){ + for(j=4; j>i; j--){ candidates[j]=candidates[j-1]; } } @@ -392,6 +392,7 @@ double offset_request(const char *host, int *status){ servers=(ntp_server_results*)malloc(sizeof(ntp_server_results)*num_hosts); if(servers==NULL) die(STATE_UNKNOWN, "can not allocate server array"); memset(servers, 0, sizeof(ntp_server_results)*num_hosts); + DBG(printf("Found %d peers to check\n", num_hosts)); /* setup each socket for writing, and the corresponding struct pollfd */ ai_tmp=ai; @@ -837,11 +838,11 @@ void print_help(void){ printf ("Copyright (c) 2006 Sean Finney\n"); printf (COPYRIGHT, copyright, email); - - printf ("%s\n", _("This plugin checks the selected ntp server")); - printf ("\n\n"); - + printf ("%s\n", _("This plugin checks the selected ntp server")); + + printf ("\n\n"); + print_usage(); printf (_(UT_HELP_VRSN)); printf (_(UT_HOST_PORT), 'p', "123"); @@ -871,11 +872,17 @@ void print_help(void){ printf(" %s\n", ("./check_ntp -H ntpserv -w 0.5 -c 1 -j -1:100 -k -1:200")); printf (_(UT_SUPPORT)); + + printf("\n"); + printf ("%s\n", _("WARNING: check_ntp is deprecated. Please use check_ntp_peer or")); + printf ("%s\n\n", _("check_ntp_time istead.")); } void print_usage(void) { - printf (_("Usage:")); - printf(" %s -H [-w ] [-c ] [-j ] [-k ] [-v verbose]\n", progname); + printf ("%s\n", _("WARNING: check_ntp is deprecated. Please use check_ntp_peer or")); + printf ("%s\n\n", _("check_ntp_time istead.")); + printf (_("Usage:")); + printf(" %s -H [-w ] [-c ] [-j ] [-k ] [-v verbose]\n", progname); } diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c index f414c328..767dcd94 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){ /* if we haven't reached the current list's end, move everyone * over one to the right, and insert the new candidate */ if(ii; j--){ + for(j=4; j>i; j--){ candidates[j]=candidates[j-1]; } } @@ -337,6 +337,7 @@ double offset_request(const char *host, int *status){ servers=(ntp_server_results*)malloc(sizeof(ntp_server_results)*num_hosts); if(servers==NULL) die(STATE_UNKNOWN, "can not allocate server array"); memset(servers, 0, sizeof(ntp_server_results)*num_hosts); + DBG(printf("Found %d peers to check\n", num_hosts)); /* setup each socket for writing, and the corresponding struct pollfd */ ai_tmp=ai; -- cgit v1.2.3-74-g34f1