aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2002-10-30 18:47:48 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2002-10-30 18:47:48 +0000
commit7cfdb411a52b4d34cdfa102014436201ed208df2 (patch)
tree720c4f44a222ae81a72df0fefb9a0580a152faf5
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
-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 f463a776..e3fac22e 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -23,6 +23,7 @@
*****************************************************************************/
#define PROGRAM check_tcp
+#define REVISION "$Revision$"
#define DESCRIPTION "Check a TCP port"
#define AUTHOR "Ethan Galstad"
#define EMAIL "nagios@nagios.org"
@@ -98,7 +99,7 @@ main (int argc, char **argv)
int result;
int i;
char buffer[MAX_INPUT_BUFFER] = "";
- char *status = NULL;
+ char *status = "";
char *output = NULL;
char *ptr = NULL;
struct timeval tv;
@@ -234,14 +235,13 @@ main (int argc, char **argv)
return STATE_CRITICAL;
if (server_send != NULL) { /* Something to send? */
- snprintf (buffer, MAX_INPUT_BUFFER - 1, "%s\r\n", server_send);
- buffer[MAX_INPUT_BUFFER - 1] = 0;
+ asprintf (&server_send, "%s\r\n", server_send);
#ifdef HAVE_SSL
if (use_ssl)
- SSL_write(ssl,buffer,strlen(buffer));
+ SSL_write(ssl, server_send, strlen (server_send));
else
#endif
- send (sd, buffer, strlen (buffer), 0);
+ send (sd, server_send, strlen (server_send), 0);
}
if (delay > 0) {
@@ -251,8 +251,6 @@ main (int argc, char **argv)
if (server_send || server_expect_count > 0) {
- asprintf (&status, "");
-
/* watch for the expect string */
#ifdef HAVE_SSL
if (use_ssl && SSL_read (ssl, buffer, MAX_INPUT_BUFFER - 1)>=0)
@@ -314,7 +312,7 @@ main (int argc, char **argv)
SERVICE,
state_text (result), elapsed_time, server_port);
- if (status)
+ if (strlen (status))
printf (" [%s]", status);
printf ("|time=%7.3f\n", elapsed_time);