summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2014-12-01 01:07:53 +0100
committerHolger Weiss <holger@zedat.fu-berlin.de>2014-12-01 01:07:53 +0100
commit99b3bfe488a856df059e933c796590eea0baae8d (patch)
tree1169ed8783ff0a6758bb765f8c9c18655e67a3f3 /plugins
parent5871123e0a5f520f810b2cfe03cef16c4c5a1aee (diff)
downloadmonitoring-plugins-99b3bfe488a856df059e933c796590eea0baae8d.tar.gz
check_ntp: Nul-terminate jitter data
Make sure the jitter response is nul-terminated before parsing the data using string functions.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_ntp.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 0a7640a7..a7d278de 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -590,6 +590,9 @@ double jitter_request(const char *host, int *status){
590 for (i = 0; i < npeers; i++){ 590 for (i = 0; i < npeers; i++){
591 /* Only query this server if it is the current sync source */ 591 /* Only query this server if it is the current sync source */
592 if (PEER_SEL(peers[i].status) >= min_peer_sel){ 592 if (PEER_SEL(peers[i].status) >= min_peer_sel){
593 char jitter_data[MAX_CM_SIZE+1];
594 size_t jitter_data_count;
595
593 num_selected++; 596 num_selected++;
594 setup_control_request(&req, OP_READVAR, 2); 597 setup_control_request(&req, OP_READVAR, 2);
595 req.assoc = peers[i].assoc; 598 req.assoc = peers[i].assoc;
@@ -623,7 +626,14 @@ double jitter_request(const char *host, int *status){
623 if(verbose) { 626 if(verbose) {
624 printf("parsing jitter from peer %.2x: ", ntohs(peers[i].assoc)); 627 printf("parsing jitter from peer %.2x: ", ntohs(peers[i].assoc));
625 } 628 }
626 startofvalue = strchr(req.data, '='); 629 if((jitter_data_count = ntohs(req.count)) >= sizeof(jitter_data)){
630 die(STATE_UNKNOWN,
631 _("jitter response too large (%lu bytes)\n"),
632 (unsigned long)jitter_data_count);
633 }
634 memcpy(jitter_data, req.data, jitter_data_count);
635 jitter_data[jitter_data_count] = '\0';
636 startofvalue = strchr(jitter_data, '=');
627 if(startofvalue != NULL) { 637 if(startofvalue != NULL) {
628 startofvalue++; 638 startofvalue++;
629 jitter = strtod(startofvalue, &nptr); 639 jitter = strtod(startofvalue, &nptr);