aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2014-12-02 10:54:55 +0100
committerGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2014-12-02 10:54:55 +0100
commitff542df44c26170afbe63a1da712264c91114e0c (patch)
tree81dd62e8885f3b3aba0824efe38abc0ffef1b7cb /plugins
parentaa1844e49b33eaf057778c828afecb095b1a2226 (diff)
parent063bc4e71d168e59437068fc386c9c3e9e25f4c6 (diff)
downloadmonitoring-plugins-ff542df44c26170afbe63a1da712264c91114e0c.tar.gz
Merge branch 'maint'
* maint: NEWS: Modify list of changes for 2.1.1 release Prepare release THANKS.in: Add new authors NEWS: Updating all the fixes check_tcp: fix help description regarding escape option check_ntp: Nul-terminate jitter data Revert "plugins/check_ntp.c - Verify struct from response" check_real: fix null termination check_ntp: fix null termination check_apt: fix memset Conflicts: NEWS
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 07622c2f..8747f904 100644
--- a/plugins/check_apt.c
+++ b/plugins/check_apt.c
@@ -224,7 +224,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount){
char *cmdline=NULL, rerrbuf[64];
/* initialize ereg as it is possible it is printed while uninitialized */
- memset(&ereg, "\0", sizeof(ereg.buffer));
+ memset(&ereg, '\0', sizeof(ereg.buffer));
if(upgrade==NO_UPGRADE) return STATE_OK;
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 09a923eb..a7d278de 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){
double jitter_request(const char *host, int *status){
int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0;
int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0;
- int peers_size=0, peer_offset=0, bytes_read=0;
+ int peers_size=0, peer_offset=0;
ntp_assoc_status_pair *peers=NULL;
ntp_control_message req;
const char *getvar = "jitter";
double rval = 0.0, jitter = -1.0;
char *startofvalue=NULL, *nptr=NULL;
void *tmp;
- int ntp_cm_ints = sizeof(uint16_t) * 5 + sizeof(uint8_t) * 2;
/* Long-winded explanation:
* Getting the jitter requires a number of steps:
@@ -591,6 +590,9 @@ double jitter_request(const char *host, int *status){
for (i = 0; i < npeers; i++){
/* Only query this server if it is the current sync source */
if (PEER_SEL(peers[i].status) >= min_peer_sel){
+ char jitter_data[MAX_CM_SIZE+1];
+ size_t jitter_data_count;
+
num_selected++;
setup_control_request(&req, OP_READVAR, 2);
req.assoc = peers[i].assoc;
@@ -609,15 +611,7 @@ double jitter_request(const char *host, int *status){
req.count = htons(MAX_CM_SIZE);
DBG(printf("recieving READVAR response...\n"));
-
- /* cov-66524 - req.data not null terminated before usage. Also covers verifying struct was returned correctly*/
- if ((bytes_read = read(conn, &req, SIZEOF_NTPCM(req))) == -1)
- die(STATE_UNKNOWN, _("Cannot read from socket: %s"), strerror(errno));
- if (bytes_read != ntp_cm_ints + req.count)
- die(STATE_UNKNOWN, _("Invalid NTP response: %d bytes read does not equal %d plus %d data segment"), bytes_read, ntp_cm_ints, req.count);
- /* else null terminate */
- strncpy(req.data[req.count], "\0", 1);
-
+ read(conn, &req, SIZEOF_NTPCM(req));
DBG(print_ntp_control_message(&req));
if(req.op&REM_ERROR && strstr(getvar, "jitter")) {
@@ -632,7 +626,14 @@ double jitter_request(const char *host, int *status){
if(verbose) {
printf("parsing jitter from peer %.2x: ", ntohs(peers[i].assoc));
}
- startofvalue = strchr(req.data, '=');
+ if((jitter_data_count = ntohs(req.count)) >= sizeof(jitter_data)){
+ die(STATE_UNKNOWN,
+ _("jitter response too large (%lu bytes)\n"),
+ (unsigned long)jitter_data_count);
+ }
+ memcpy(jitter_data, req.data, jitter_data_count);
+ jitter_data[jitter_data_count] = '\0';
+ startofvalue = strchr(jitter_data, '=');
if(startofvalue != NULL) {
startofvalue++;
jitter = strtod(startofvalue, &nptr);
diff --git a/plugins/check_real.c b/plugins/check_real.c
index e7ab9d04..00bd4d20 100644
--- a/plugins/check_real.c
+++ b/plugins/check_real.c
@@ -178,7 +178,7 @@ main (int argc, char **argv)
/* watch for the REAL connection string */
result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0);
- buffer[result] = "\0"; /* null terminate recieved buffer */
+ buffer[result] = '\0'; /* null terminate recieved buffer */
/* return a CRITICAL status if we couldn't read any data */
if (result == -1) {
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index fc0adba0..63f9fd9c 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -643,7 +643,7 @@ print_help (void)
printf (UT_IPv46);
printf (" %s\n", "-E, --escape");
- printf (" %s\n", _("Can use \\n, \\r, \\t or \\ in send or quit string. Must come before send or quit option"));
+ printf (" %s\n", _("Can use \\n, \\r, \\t or \\\\ in send or quit string. Must come before send or quit option"));
printf (" %s\n", _("Default: nothing added to send, \\r\\n added to end of quit"));
printf (" %s\n", "-s, --send=STRING");
printf (" %s\n", _("String to send to the server"));