summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/check_tcp.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index c537729..140915a 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -239,15 +239,17 @@ main (int argc, char **argv)
239 239
240 if (server_send || server_expect_count > 0) { 240 if (server_send || server_expect_count > 0) {
241 241
242 asprintf (&status, "");
243
242 /* watch for the expect string */ 244 /* watch for the expect string */
243#ifdef HAVE_SSL 245#ifdef HAVE_SSL
244 if (use_ssl && SSL_read (ssl, buffer, MAX_INPUT_BUFFER - 1)>=0) 246 if (use_ssl && SSL_read (ssl, buffer, MAX_INPUT_BUFFER - 1)>=0)
245 status = strscat(status,buffer); 247 asprintf (&status, "%s%s", status, buffer);
246 else 248 else
247#endif 249#endif
248 { 250 {
249 if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) >= 0) 251 if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) >= 0)
250 status = strscat (status, buffer); 252 asprintf (&status, "%s%s", status, buffer);
251 } 253 }
252 strip (status); 254 strip (status);
253 255
@@ -260,7 +262,8 @@ main (int argc, char **argv)
260 262
261 if (server_expect_count > 0) { 263 if (server_expect_count > 0) {
262 for (i = 0;; i++) { 264 for (i = 0;; i++) {
263 printf ("%d %d\n", i, server_expect_count); 265 if (verbose)
266 printf ("%d %d\n", i, server_expect_count);
264 if (i >= server_expect_count) 267 if (i >= server_expect_count)
265 terminate (STATE_WARNING, "Invalid response from host\n"); 268 terminate (STATE_WARNING, "Invalid response from host\n");
266 if (strstr (status, server_expect[i])) 269 if (strstr (status, server_expect[i]))
@@ -425,7 +428,7 @@ process_arguments (int argc, char **argv)
425 case 's': 428 case 's':
426 server_send = optarg; 429 server_send = optarg;
427 break; 430 break;
428 case 'e': 431 case 'e': /* expect string (may be repeated) */
429 EXPECT = NULL; 432 EXPECT = NULL;
430 if (server_expect_count == 0) 433 if (server_expect_count == 0)
431 server_expect = malloc (++server_expect_count); 434 server_expect = malloc (++server_expect_count);