SF.net SVN: nagiosplug:[2189] nagiosplug/trunk

[email protected]
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
Revision: 2189
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2189&view=rev
Author:   dermoth
Date:     2009-05-01 09:19:23 +0000 (Fri, 01 May 2009)

Log Message:
-----------
Fixed crash from check_nt when -H unspecified or given multiple times (sf.net #2731755, debian #521097)

From: Matthias Eble <[email protected]>

Modified Paths:
--------------
    nagiosplug/trunk/NEWS
    nagiosplug/trunk/plugins/check_nt.c
    nagiosplug/trunk/plugins/tests/check_nt.t

Modified: nagiosplug/trunk/NEWS
===================================================================
--- nagiosplug/trunk/NEWS	2009-04-02 23:26:46 UTC (rev 2188)
+++ nagiosplug/trunk/NEWS	2009-05-01 09:19:23 UTC (rev 2189)
@@ -23,6 +23,7 @@
 	check_http --onredirect=sticky follows using the same IP address (sf.net #2550208)
 	check_http --onredirect=stickyport also follows the same port
 	Fixed coredump from check_nt when invalid drive is specified (#2179754 - Olli Hauer)
+	Fixed crash from check_nt when -H unspecified or given multiple times (sf.net #2731755, debian #521097)
 	Fixed passing of quotes in OID for check_snmp (#1985230 - Jan Wagner, patch by John Barbuto)
 	Fixed check_http sending HTTP/1.0 with v1.1 headers (#2638765)
 	Fixed check_http not timing-out on redirects

Modified: nagiosplug/trunk/plugins/check_nt.c
===================================================================
--- nagiosplug/trunk/plugins/check_nt.c	2009-04-02 23:26:46 UTC (rev 2188)
+++ nagiosplug/trunk/plugins/check_nt.c	2009-05-01 09:19:23 UTC (rev 2189)
@@ -522,7 +522,6 @@
 				print_revision(progname, NP_VERSION);
 				exit(STATE_OK);
 			case 'H': /* hostname */
-				if (server_address)	free(server_address);
 				server_address = optarg;
 				break;
 			case 's': /* password */
@@ -585,6 +584,8 @@
 			}
 
 	}
+	if (server_address == NULL)
+		usage4 (_("You must provide a server address or host name"));
 
 	if (vars_to_check==CHECK_NONE)
 		return ERROR;

Modified: nagiosplug/trunk/plugins/tests/check_nt.t
===================================================================
--- nagiosplug/trunk/plugins/tests/check_nt.t	2009-04-02 23:26:46 UTC (rev 2188)
+++ nagiosplug/trunk/plugins/tests/check_nt.t	2009-05-01 09:19:23 UTC (rev 2189)
@@ -59,7 +59,7 @@
 }
 
 if (-x "./check_nt") {
-	plan tests => 4;
+	plan tests => 5;
 } else {
 	plan skip_all => "No check_nt compiled";
 }
@@ -75,3 +75,6 @@
 is( $result->return_code, 3, "USEDDISKSPACE d - invalid");
 is( $result->output, "Free disk space : Invalid drive", "Output right" );
 
+$result = NPTest->testCmd( "./check_nt -v USEDDISKSPACE -l d" );
+is( $result->return_code, 3, "Fail if -H missing");
+


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.