summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_apt.c2
-rw-r--r--plugins/check_ntp.c25
-rw-r--r--plugins/check_real.c2
-rw-r--r--plugins/check_tcp.c2
4 files changed, 16 insertions, 15 deletions
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
index 07622c2..8747f90 100644
--- a/plugins/check_apt.c
+++ b/plugins/check_apt.c
@@ -224,7 +224,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount){
224 char *cmdline=NULL, rerrbuf[64]; 224 char *cmdline=NULL, rerrbuf[64];
225 225
226 /* initialize ereg as it is possible it is printed while uninitialized */ 226 /* initialize ereg as it is possible it is printed while uninitialized */
227 memset(&ereg, "\0", sizeof(ereg.buffer)); 227 memset(&ereg, '\0', sizeof(ereg.buffer));
228 228
229 if(upgrade==NO_UPGRADE) return STATE_OK; 229 if(upgrade==NO_UPGRADE) return STATE_OK;
230 230
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 09a923e..a7d278d 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -517,14 +517,13 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
517double jitter_request(const char *host, int *status){ 517double jitter_request(const char *host, int *status){
518 int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0; 518 int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0;
519 int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0; 519 int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0;
520 int peers_size=0, peer_offset=0, bytes_read=0; 520 int peers_size=0, peer_offset=0;
521 ntp_assoc_status_pair *peers=NULL; 521 ntp_assoc_status_pair *peers=NULL;
522 ntp_control_message req; 522 ntp_control_message req;
523 const char *getvar = "jitter"; 523 const char *getvar = "jitter";
524 double rval = 0.0, jitter = -1.0; 524 double rval = 0.0, jitter = -1.0;
525 char *startofvalue=NULL, *nptr=NULL; 525 char *startofvalue=NULL, *nptr=NULL;
526 void *tmp; 526 void *tmp;
527 int ntp_cm_ints = sizeof(uint16_t) * 5 + sizeof(uint8_t) * 2;
528 527
529 /* Long-winded explanation: 528 /* Long-winded explanation:
530 * Getting the jitter requires a number of steps: 529 * Getting the jitter requires a number of steps:
@@ -591,6 +590,9 @@ double jitter_request(const char *host, int *status){
591 for (i = 0; i < npeers; i++){ 590 for (i = 0; i < npeers; i++){
592 /* Only query this server if it is the current sync source */ 591 /* Only query this server if it is the current sync source */
593 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
594 num_selected++; 596 num_selected++;
595 setup_control_request(&req, OP_READVAR, 2); 597 setup_control_request(&req, OP_READVAR, 2);
596 req.assoc = peers[i].assoc; 598 req.assoc = peers[i].assoc;
@@ -609,15 +611,7 @@ double jitter_request(const char *host, int *status){
609 611
610 req.count = htons(MAX_CM_SIZE); 612 req.count = htons(MAX_CM_SIZE);
611 DBG(printf("recieving READVAR response...\n")); 613 DBG(printf("recieving READVAR response...\n"));
612 614 read(conn, &req, SIZEOF_NTPCM(req));
613 /* cov-66524 - req.data not null terminated before usage. Also covers verifying struct was returned correctly*/
614 if ((bytes_read = read(conn, &req, SIZEOF_NTPCM(req))) == -1)
615 die(STATE_UNKNOWN, _("Cannot read from socket: %s"), strerror(errno));
616 if (bytes_read != ntp_cm_ints + req.count)
617 die(STATE_UNKNOWN, _("Invalid NTP response: %d bytes read does not equal %d plus %d data segment"), bytes_read, ntp_cm_ints, req.count);
618 /* else null terminate */
619 strncpy(req.data[req.count], "\0", 1);
620
621 DBG(print_ntp_control_message(&req)); 615 DBG(print_ntp_control_message(&req));
622 616
623 if(req.op&REM_ERROR && strstr(getvar, "jitter")) { 617 if(req.op&REM_ERROR && strstr(getvar, "jitter")) {
@@ -632,7 +626,14 @@ double jitter_request(const char *host, int *status){
632 if(verbose) { 626 if(verbose) {
633 printf("parsing jitter from peer %.2x: ", ntohs(peers[i].assoc)); 627 printf("parsing jitter from peer %.2x: ", ntohs(peers[i].assoc));
634 } 628 }
635 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, '=');
636 if(startofvalue != NULL) { 637 if(startofvalue != NULL) {
637 startofvalue++; 638 startofvalue++;
638 jitter = strtod(startofvalue, &nptr); 639 jitter = strtod(startofvalue, &nptr);
diff --git a/plugins/check_real.c b/plugins/check_real.c
index e7ab9d0..00bd4d2 100644
--- a/plugins/check_real.c
+++ b/plugins/check_real.c
@@ -178,7 +178,7 @@ main (int argc, char **argv)
178 178
179 /* watch for the REAL connection string */ 179 /* watch for the REAL connection string */
180 result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0); 180 result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0);
181 buffer[result] = "\0"; /* null terminate recieved buffer */ 181 buffer[result] = '\0'; /* null terminate recieved buffer */
182 182
183 /* return a CRITICAL status if we couldn't read any data */ 183 /* return a CRITICAL status if we couldn't read any data */
184 if (result == -1) { 184 if (result == -1) {
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index fc0adba..63f9fd9 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -643,7 +643,7 @@ print_help (void)
643 printf (UT_IPv46); 643 printf (UT_IPv46);
644 644
645 printf (" %s\n", "-E, --escape"); 645 printf (" %s\n", "-E, --escape");
646 printf (" %s\n", _("Can use \\n, \\r, \\t or \\ in send or quit string. Must come before send or quit option")); 646 printf (" %s\n", _("Can use \\n, \\r, \\t or \\\\ in send or quit string. Must come before send or quit option"));
647 printf (" %s\n", _("Default: nothing added to send, \\r\\n added to end of quit")); 647 printf (" %s\n", _("Default: nothing added to send, \\r\\n added to end of quit"));
648 printf (" %s\n", "-s, --send=STRING"); 648 printf (" %s\n", "-s, --send=STRING");
649 printf (" %s\n", _("String to send to the server")); 649 printf (" %s\n", _("String to send to the server"));