[Nagiosplug-checkins] CVS: nagiosplug/plugins check_dns.c,1.13,1.14

Karl DeBisschop kdebisschop at users.sourceforge.net
Sat May 31 07:40:03 CEST 2003


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

Modified Files:
	check_dns.c 
Log Message:
first revised patch failed to trap the "break" in while()

Index: check_dns.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dns.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** check_dns.c	13 Mar 2003 21:14:25 -0000	1.13
--- check_dns.c	31 May 2003 14:39:21 -0000	1.14
***************
*** 140,149 ****
  				for (; *temp_buffer != '\0' && *temp_buffer == ' '; temp_buffer++)
  					/* NOOP */;
! 				address = strscpy (address, temp_buffer);
  				strip (address);
  				result = STATE_OK;
  			}
  			else {
! 				output = strscpy (output, "Unknown error (plugin)");
  				result = STATE_WARNING;
  			}
--- 140,153 ----
  				for (; *temp_buffer != '\0' && *temp_buffer == ' '; temp_buffer++)
  					/* NOOP */;
! 				address = strdup (temp_buffer);
  				strip (address);
+ 				if (address==NULL || strlen(address)==0)
+ 					terminate (STATE_CRITICAL,
+ 					           "DNS CRITICAL - '%s' returned empty host name string\n",
+ 					           NSLOOKUP_COMMAND);
  				result = STATE_OK;
  			}
  			else {
! 				output = strdup ("Unknown error (plugin)");
  				result = STATE_WARNING;
  			}
***************
*** 180,188 ****
  	}
  
  	/* compare to expected address */
  	if (result == STATE_OK && match_expected_address && strcmp(address, expected_address)) {
! 	        result = STATE_CRITICAL;
! 	        asprintf(&output, "expected %s but got %s", expected_address, address);
! 		}
  	
  	elapsed_time = delta_time (tv);
--- 184,199 ----
  	}
  
+ 	/* If we got here, we should have an address string, 
+ 	   and we can segfault if we do not */
+ 	if (address==NULL || strlen(address)==0)
+ 		terminate (STATE_CRITICAL,
+ 		           "DNS CRITICAL - '%s' output parsing exited with no address\n",
+ 		           NSLOOKUP_COMMAND);
+ 
  	/* compare to expected address */
  	if (result == STATE_OK && match_expected_address && strcmp(address, expected_address)) {
! 		result = STATE_CRITICAL;
! 		asprintf(&output, "expected %s but got %s", expected_address, address);
! 	}
  	
  	elapsed_time = delta_time (tv);





More information about the Commits mailing list