[Nagiosplug-checkins] CVS: nagiosplug/plugins check_tcp.c,1.5,1.6

Karl DeBisschop kdebisschop at users.sourceforge.net
Wed Oct 30 10:48:06 CET 2002


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory usw-pr-cvs1:/tmp/cvs-serv7742/plugins

Modified Files:
	check_tcp.c 
Log Message:
replace fixed-lentgh buffer with asprintf

Index: check_tcp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_tcp.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** check_tcp.c	22 Oct 2002 08:54:27 -0000	1.5
--- check_tcp.c	30 Oct 2002 18:47:48 -0000	1.6
***************
*** 24,27 ****
--- 24,28 ----
  
  #define PROGRAM check_tcp
+ #define REVISION "$Revision$"
  #define DESCRIPTION "Check a TCP port"
  #define AUTHOR "Ethan Galstad"
***************
*** 99,103 ****
  	int i;
  	char buffer[MAX_INPUT_BUFFER] = "";
! 	char *status = NULL;
  	char *output = NULL;
  	char *ptr = NULL;
--- 100,104 ----
  	int i;
  	char buffer[MAX_INPUT_BUFFER] = "";
! 	char *status = "";
  	char *output = NULL;
  	char *ptr = NULL;
***************
*** 235,246 ****
  
  	if (server_send != NULL) {		/* Something to send? */
! 		snprintf (buffer, MAX_INPUT_BUFFER - 1, "%s\r\n", server_send);
! 		buffer[MAX_INPUT_BUFFER - 1] = 0;
  #ifdef HAVE_SSL
  		if (use_ssl)
! 			SSL_write(ssl,buffer,strlen(buffer));
  		else
  #endif
! 			send (sd, buffer, strlen (buffer), 0);
  	}
  
--- 236,246 ----
  
  	if (server_send != NULL) {		/* Something to send? */
! 		asprintf (&server_send, "%s\r\n", server_send);
  #ifdef HAVE_SSL
  		if (use_ssl)
! 			SSL_write(ssl, server_send, strlen (server_send));
  		else
  #endif
! 			send (sd, server_send, strlen (server_send), 0);
  	}
  
***************
*** 252,257 ****
  	if (server_send || server_expect_count > 0) {
  
- 		asprintf (&status, "");
- 
  		/* watch for the expect string */
  #ifdef HAVE_SSL
--- 252,255 ----
***************
*** 315,319 ****
  		 state_text (result), elapsed_time, server_port);
  
! 	if (status)
  		printf (" [%s]", status);
  
--- 313,317 ----
  		 state_text (result), elapsed_time, server_port);
  
! 	if (strlen (status))
  		printf (" [%s]", status);
  





More information about the Commits mailing list