diff options
Diffstat (limited to 'plugins/check_tcp.c')
-rw-r--r-- | plugins/check_tcp.c | 15 |
1 files 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; | |||
70 | static char *server_quit = NULL; | 70 | static char *server_quit = NULL; |
71 | static char **server_expect; | 71 | static char **server_expect; |
72 | static size_t server_expect_count = 0; | 72 | static size_t server_expect_count = 0; |
73 | static size_t maxbytes = 0; | 73 | static ssize_t maxbytes = 0; |
74 | static char **warn_codes = NULL; | 74 | static char **warn_codes = NULL; |
75 | static size_t warn_codes_count = 0; | 75 | static size_t warn_codes_count = 0; |
76 | static char **crit_codes = NULL; | 76 | static char **crit_codes = NULL; |
@@ -105,7 +105,6 @@ main (int argc, char **argv) | |||
105 | char *status = NULL; | 105 | char *status = NULL; |
106 | struct timeval tv; | 106 | struct timeval tv; |
107 | struct timeval timeout; | 107 | struct timeval timeout; |
108 | size_t len; | ||
109 | int match = -1; | 108 | int match = -1; |
110 | fd_set rfds; | 109 | fd_set rfds; |
111 | 110 | ||
@@ -120,10 +119,10 @@ main (int argc, char **argv) | |||
120 | if(progname != NULL) progname++; | 119 | if(progname != NULL) progname++; |
121 | else progname = argv[0]; | 120 | else progname = argv[0]; |
122 | 121 | ||
123 | len = strlen(progname); | 122 | size_t prog_name_len = strlen(progname); |
124 | if(len > 6 && !memcmp(progname, "check_", 6)) { | 123 | if(prog_name_len > 6 && !memcmp(progname, "check_", 6)) { |
125 | SERVICE = strdup(progname + 6); | 124 | SERVICE = strdup(progname + 6); |
126 | for(size_t i = 0; i < len - 6; i++) | 125 | for(size_t i = 0; i < prog_name_len - 6; i++) |
127 | SERVICE[i] = toupper(SERVICE[i]); | 126 | SERVICE[i] = toupper(SERVICE[i]); |
128 | } | 127 | } |
129 | 128 | ||
@@ -279,11 +278,12 @@ main (int argc, char **argv) | |||
279 | } | 278 | } |
280 | 279 | ||
281 | /* if(len) later on, we know we have a non-NULL response */ | 280 | /* if(len) later on, we know we have a non-NULL response */ |
282 | len = 0; | 281 | ssize_t len = 0; |
282 | |||
283 | if (server_expect_count) { | 283 | if (server_expect_count) { |
284 | ssize_t received = 0; | ||
284 | 285 | ||
285 | /* watch for the expect string */ | 286 | /* watch for the expect string */ |
286 | size_t received = 0; | ||
287 | while ((received = my_recv(buffer, sizeof(buffer))) > 0) { | 287 | while ((received = my_recv(buffer, sizeof(buffer))) > 0) { |
288 | status = realloc(status, len + received + 1); | 288 | status = realloc(status, len + received + 1); |
289 | memcpy(&status[len], buffer, received); | 289 | memcpy(&status[len], buffer, received); |
@@ -307,6 +307,7 @@ main (int argc, char **argv) | |||
307 | if(select(sd + 1, &rfds, NULL, NULL, &timeout) <= 0) | 307 | if(select(sd + 1, &rfds, NULL, NULL, &timeout) <= 0) |
308 | break; | 308 | break; |
309 | } | 309 | } |
310 | |||
310 | if (match == NP_MATCH_RETRY) | 311 | if (match == NP_MATCH_RETRY) |
311 | match = NP_MATCH_FAILURE; | 312 | match = NP_MATCH_FAILURE; |
312 | 313 | ||