[monitoring-plugins] check_tcp: Fixes an error with using the wrong ...
RincewindsHat
git at monitoring-plugins.org
Sun Oct 29 11:10:12 CET 2023
Module: monitoring-plugins
Branch: master
Commit: eead88edda047843b911afd7b63e7decfee306ce
Author: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com>
Date: Thu Oct 19 13:46:15 2023 +0200
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=eead88e
check_tcp: Fixes an error with using the wrong type for a variable
---
plugins/check_tcp.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 054f1a3..01dd35e 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -70,7 +70,7 @@ static char *server_send = NULL;
static char *server_quit = NULL;
static char **server_expect;
static size_t server_expect_count = 0;
-static size_t maxbytes = 0;
+static ssize_t maxbytes = 0;
static char **warn_codes = NULL;
static size_t warn_codes_count = 0;
static char **crit_codes = NULL;
@@ -105,7 +105,6 @@ main (int argc, char **argv)
char *status = NULL;
struct timeval tv;
struct timeval timeout;
- size_t len;
int match = -1;
fd_set rfds;
@@ -120,10 +119,10 @@ main (int argc, char **argv)
if(progname != NULL) progname++;
else progname = argv[0];
- len = strlen(progname);
- if(len > 6 && !memcmp(progname, "check_", 6)) {
+ size_t prog_name_len = strlen(progname);
+ if(prog_name_len > 6 && !memcmp(progname, "check_", 6)) {
SERVICE = strdup(progname + 6);
- for(size_t i = 0; i < len - 6; i++)
+ for(size_t i = 0; i < prog_name_len - 6; i++)
SERVICE[i] = toupper(SERVICE[i]);
}
@@ -279,11 +278,12 @@ main (int argc, char **argv)
}
/* if(len) later on, we know we have a non-NULL response */
- len = 0;
+ ssize_t len = 0;
+
if (server_expect_count) {
+ ssize_t received = 0;
/* watch for the expect string */
- size_t received = 0;
while ((received = my_recv(buffer, sizeof(buffer))) > 0) {
status = realloc(status, len + received + 1);
memcpy(&status[len], buffer, received);
@@ -307,6 +307,7 @@ main (int argc, char **argv)
if(select(sd + 1, &rfds, NULL, NULL, &timeout) <= 0)
break;
}
+
if (match == NP_MATCH_RETRY)
match = NP_MATCH_FAILURE;
More information about the Commits
mailing list