[Nagiosplug-checkins] CVS: nagiosplug/plugins check_tcp.c,1.12,1.13

Karl DeBisschop kdebisschop at users.sourceforge.net
Tue Feb 18 14:22:05 CET 2003


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv19565/plugins

Modified Files:
	check_tcp.c 
Log Message:
failed if header was more than 1023 bytes

Index: check_tcp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_tcp.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** check_tcp.c	16 Jan 2003 05:20:15 -0000	1.12
--- check_tcp.c	18 Feb 2003 22:20:01 -0000	1.13
***************
*** 58,67 ****
  #endif
  
! #define TCP_PROTOCOL 1
! #define UDP_PROTOCOL 2
  
  int process_arguments (int, char **);
  void print_usage (void);
  void print_help (void);
  
  char *progname = "check_tcp";
--- 58,71 ----
  #endif
  
! enum {
! 	TCP_PROTOCOL = 1,
! 	UDP_PROTOCOL = 2,
! 	MAXBUF = 1024
! };
  
  int process_arguments (int, char **);
  void print_usage (void);
  void print_help (void);
+ int my_recv (void);
  
  char *progname = "check_tcp";
***************
*** 92,95 ****
--- 96,100 ----
  int use_ssl = FALSE;
  int sd = 0;
+ char *buffer = "";
  
  int
***************
*** 98,102 ****
  	int result;
  	int i;
- 	char *buffer = "";
  	char *status = "";
  	struct timeval tv;
--- 103,106 ----
***************
*** 249,261 ****
  	if (server_send || server_expect_count > 0) {
  
! 		buffer = malloc (MAX_INPUT_BUFFER);
  		/* watch for the expect string */
! #ifdef HAVE_SSL
! 		if (use_ssl && SSL_read (ssl, buffer, MAX_INPUT_BUFFER - 1) > 0)
  			asprintf (&status, "%s%s", status, buffer);
! 		else
! #endif
! 			if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) > 0)
! 				asprintf (&status, "%s%s", status, buffer);
  
  		/* return a CRITICAL status if we couldn't read any data */
--- 253,265 ----
  	if (server_send || server_expect_count > 0) {
  
! 		buffer = malloc (MAXBUF);
! 		memset (buffer, '\0', MAXBUF);
  		/* watch for the expect string */
! 		while ((i = my_recv ()) > 0) {
! 			buffer[i] = '\0';
  			asprintf (&status, "%s%s", status, buffer);
! 			if (buffer[i-2] == '\r' && buffer[i-1] == '\n')
! 				break;
! 		}
  
  		/* return a CRITICAL status if we couldn't read any data */
***************
*** 280,284 ****
  	}
  
! 	if (server_quit)
  #ifdef HAVE_SSL
  		if (use_ssl) {
--- 284,288 ----
  	}
  
! 	if (server_quit != NULL)
  #ifdef HAVE_SSL
  		if (use_ssl) {
***************
*** 573,574 ****
--- 577,598 ----
  #endif
  
+ 
+ 
+ int
+ my_recv (void)
+ {
+ 	int i;
+ 
+ #ifdef HAVE_SSL
+ 	if (use_ssl) {
+ 		i = SSL_read (ssl, buffer, MAXBUF - 1);
+ 	}
+ 	else {
+ #endif
+ 		i = read (sd, buffer, MAXBUF - 1);
+ #ifdef HAVE_SSL
+ 	}
+ #endif
+ 
+ 	return i;
+ }





More information about the Commits mailing list