diff options
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-01-05 14:09:29 +0000 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-01-05 14:09:29 +0000 |
commit | b5d3997aa39169637871a4bca5f860fae21aba3e (patch) | |
tree | 4c6b9e0ac14a45406db2c83a36049e0ea420c4eb /plugins | |
parent | f83981580eced39b10e096b8eb9a6c4e6434e772 (diff) | |
download | monitoring-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')
-rw-r--r-- | plugins/check_ntp.c | 21 | ||||
-rw-r--r-- | plugins/check_ntp_time.c | 3 |
2 files changed, 16 insertions, 8 deletions
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){ | |||
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 | ||
876 | void | 881 | void |
877 | print_usage(void) | 882 | print_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 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){ | |||
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; |