summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2002-10-30 18:47:48 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2002-10-30 18:47:48 (GMT)
commit7cfdb411a52b4d34cdfa102014436201ed208df2 (patch)
tree720c4f44a222ae81a72df0fefb9a0580a152faf5 /plugins
parent1da8bf725cf558d90134a6a56fac6d371dea63ec (diff)
downloadmonitoring-plugins-7cfdb411a52b4d34cdfa102014436201ed208df2.tar.gz
replace fixed-lentgh buffer with asprintf
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@168 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_tcp.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index f463a77..e3fac22 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -23,6 +23,7 @@
23 *****************************************************************************/ 23 *****************************************************************************/
24 24
25#define PROGRAM check_tcp 25#define PROGRAM check_tcp
26#define REVISION "$Revision$"
26#define DESCRIPTION "Check a TCP port" 27#define DESCRIPTION "Check a TCP port"
27#define AUTHOR "Ethan Galstad" 28#define AUTHOR "Ethan Galstad"
28#define EMAIL "nagios@nagios.org" 29#define EMAIL "nagios@nagios.org"
@@ -98,7 +99,7 @@ main (int argc, char **argv)
98 int result; 99 int result;
99 int i; 100 int i;
100 char buffer[MAX_INPUT_BUFFER] = ""; 101 char buffer[MAX_INPUT_BUFFER] = "";
101 char *status = NULL; 102 char *status = "";
102 char *output = NULL; 103 char *output = NULL;
103 char *ptr = NULL; 104 char *ptr = NULL;
104 struct timeval tv; 105 struct timeval tv;
@@ -234,14 +235,13 @@ main (int argc, char **argv)
234 return STATE_CRITICAL; 235 return STATE_CRITICAL;
235 236
236 if (server_send != NULL) { /* Something to send? */ 237 if (server_send != NULL) { /* Something to send? */
237 snprintf (buffer, MAX_INPUT_BUFFER - 1, "%s\r\n", server_send); 238 asprintf (&server_send, "%s\r\n", server_send);
238 buffer[MAX_INPUT_BUFFER - 1] = 0;
239#ifdef HAVE_SSL 239#ifdef HAVE_SSL
240 if (use_ssl) 240 if (use_ssl)
241 SSL_write(ssl,buffer,strlen(buffer)); 241 SSL_write(ssl, server_send, strlen (server_send));
242 else 242 else
243#endif 243#endif
244 send (sd, buffer, strlen (buffer), 0); 244 send (sd, server_send, strlen (server_send), 0);
245 } 245 }
246 246
247 if (delay > 0) { 247 if (delay > 0) {
@@ -251,8 +251,6 @@ main (int argc, char **argv)
251 251
252 if (server_send || server_expect_count > 0) { 252 if (server_send || server_expect_count > 0) {
253 253
254 asprintf (&status, "");
255
256 /* watch for the expect string */ 254 /* watch for the expect string */
257#ifdef HAVE_SSL 255#ifdef HAVE_SSL
258 if (use_ssl && SSL_read (ssl, buffer, MAX_INPUT_BUFFER - 1)>=0) 256 if (use_ssl && SSL_read (ssl, buffer, MAX_INPUT_BUFFER - 1)>=0)
@@ -314,7 +312,7 @@ main (int argc, char **argv)
314 SERVICE, 312 SERVICE,
315 state_text (result), elapsed_time, server_port); 313 state_text (result), elapsed_time, server_port);
316 314
317 if (status) 315 if (strlen (status))
318 printf (" [%s]", status); 316 printf (" [%s]", status);
319 317
320 printf ("|time=%7.3f\n", elapsed_time); 318 printf ("|time=%7.3f\n", elapsed_time);