[Nagiosplug-checkins] CVS: nagiosplug/plugins check_http.c,1.45,1.46

Karl DeBisschop kdebisschop at users.sourceforge.net
Tue Aug 19 05:01:03 CEST 2003


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

Modified Files:
	check_http.c 
Log Message:
*BUGFIX: LWS is not required betwwen "Location:" header field name and field value

Index: check_http.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_http.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -r1.45 -r1.46
*** check_http.c	19 Aug 2003 11:19:09 -0000	1.45
--- check_http.c	19 Aug 2003 11:41:08 -0000	1.46
***************
*** 305,315 ****
  		/* Note: H, I, and u must be malloc'd or will fail on redirects */
  		case 'H': /* Host Name (virtual host) */
!  			host_name = optarg;
  			break;
  		case 'I': /* Server IP-address */
!  			server_address = optarg;
  			break;
  		case 'u': /* URL path */
! 			asprintf (&server_url, "%s", optarg);
  			server_url_length = strlen (server_url);
  			break;
--- 305,315 ----
  		/* Note: H, I, and u must be malloc'd or will fail on redirects */
  		case 'H': /* Host Name (virtual host) */
!  			host_name = strdup (optarg);
  			break;
  		case 'I': /* Server IP-address */
!  			server_address = strdup (optarg);
  			break;
  		case 'u': /* URL path */
! 			server_url = strdup (optarg);
  			server_url_length = strlen (server_url);
  			break;
***************
*** 329,333 ****
  			if (http_method || http_post_data) break;
  			http_method = strdup("POST");
! 			http_post_data = optarg;
  			break;
  		case 's': /* string or substring */
--- 329,333 ----
  			if (http_method || http_post_data) break;
  			http_method = strdup("POST");
! 			http_post_data = strdup (optarg);
  			break;
  		case 's': /* string or substring */
***************
*** 388,392 ****
  
  	if (host_name == NULL && c < argc)
!  		asprintf (&host_name, "%s", argv[c++]);
  
  	if (server_address == NULL) {
--- 388,392 ----
  
  	if (host_name == NULL && c < argc)
!  		host_name = strdup (argv[c++]);
  
  	if (server_address == NULL) {
***************
*** 457,465 ****
  #define URI_PORT ":%[0123456789]"
  #define URI_PATH "%[-_.!~*'();/?:@&=+$,%#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]"
! #define HD1 HDR_LOCATION URI_HTTP URI_HOST URI_PORT URI_PATH
! #define HD2 HDR_LOCATION URI_HTTP URI_HOST URI_PATH
! #define HD3 HDR_LOCATION URI_HTTP URI_HOST URI_PORT
! #define HD4 HDR_LOCATION URI_HTTP URI_HOST
! #define HD5 HDR_LOCATION URI_PATH
  
  int
--- 457,465 ----
  #define URI_PORT ":%[0123456789]"
  #define URI_PATH "%[-_.!~*'();/?:@&=+$,%#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]"
! #define HD1 URI_HTTP URI_HOST URI_PORT URI_PATH
! #define HD2 URI_HTTP URI_HOST URI_PATH
! #define HD3 URI_HTTP URI_HOST URI_PORT
! #define HD4 URI_HTTP URI_HOST
! #define HD5 URI_PATH
  
  int
***************
*** 477,480 ****
--- 477,481 ----
  	char *pos;
  	char *x;
+ 	char xx[2];
  	char *orig_url;
  	long microsec;
***************
*** 591,595 ****
  
  	if (verbose)
! 		printf ("Page is %d characters\n", pagesize);
  
  	/* find status line and null-terminate it */
--- 592,596 ----
  
  	if (verbose)
! 		printf ("%s://%s:%d%s is %d characters\n", server_type, server_address, server_port, server_url, pagesize);
  
  	/* find status line and null-terminate it */
***************
*** 670,684 ****
  			if (onredirect == STATE_DEPENDENT) {
  
  				asprintf (&orig_url, "%s", server_url);
  				pos = header;
  				while (pos) {
! 					server_address = realloc (server_address, MAX_IPV4_HOSTLENGTH + 1);
! 					if (server_address == NULL)
! 						die (STATE_UNKNOWN,_("ERROR: could not allocate server_address"));
! 					if (strcspn (pos, "\r\n") > (size_t)server_url_length) {
! 						server_url = realloc (server_url, strcspn (pos, "\r\n"));
! 						if (server_url == NULL)
! 							die (STATE_UNKNOWN, _("ERROR: could not allocate server_url"));
! 						server_url_length = strcspn (pos, "\r\n");
  					}
  					/* HDR_LOCATION, URI_HTTP, URI_HOST, URI_PORT, URI_PATH */
--- 671,695 ----
  			if (onredirect == STATE_DEPENDENT) {
  
+ 				server_address = realloc (server_address, MAX_IPV4_HOSTLENGTH + 1);
+ 				if (server_address == NULL)
+ 					die (STATE_UNKNOWN,_("ERROR: could not allocate server_address"));
+ 
  				asprintf (&orig_url, "%s", server_url);
+ 				if (strcspn (pos, "\r\n") > (size_t)server_url_length) {
+ 					server_url = realloc (server_url, strcspn (pos, "\r\n"));
+ 					if (server_url == NULL)
+ 						die (STATE_UNKNOWN, _("ERROR: could not allocate server_url"));
+ 					server_url_length = strcspn (pos, "\r\n");
+ 				}
+ 
  				pos = header;
  				while (pos) {
! 					if (sscanf (pos, "%[Ll]%*[Oo]%*[Cc]%*[Aa]%*[Tt]%*[Ii]%*[Oo]%*[Nn]:%n", xx, &i) > 0) {
! 						pos += i;
! 						pos += strspn (pos, " \t\r\n");
! 					} else {
! 						pos += (size_t) strcspn (pos, "\r\n");
! 						pos += (size_t) strspn (pos, "\r\n");
! 						continue;
  					}
  					/* HDR_LOCATION, URI_HTTP, URI_HOST, URI_PORT, URI_PATH */
***************
*** 724,729 ****
  						check_http ();
  					} 					
- 					pos += (size_t) strcspn (pos, "\r\n");
- 					pos += (size_t) strspn (pos, "\r\n");
  				} /* end while (pos) */
  				printf (_("UNKNOWN - Could not find redirect location - %s%s"),
--- 735,738 ----





More information about the Commits mailing list