From 8e4c885ee1a8f057fbe550e2d5b85cc8079564df Mon Sep 17 00:00:00 2001 From: Matthias Eble Date: Fri, 1 May 2009 11:16:37 +0200 Subject: Fixed crash from check_nt when -H unspecified or given multiple times (sf.net #2731755, debian #521097) diff --git a/NEWS b/NEWS index e9e24a7..932b217 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,7 @@ This file documents the major additions and syntax changes between releases. 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 diff --git a/plugins/check_nt.c b/plugins/check_nt.c index ec944e4..d038efe 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c @@ -522,7 +522,6 @@ int process_arguments(int argc, char **argv){ 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 @@ int process_arguments(int argc, char **argv){ } } + if (server_address == NULL) + usage4 (_("You must provide a server address or host name")); if (vars_to_check==CHECK_NONE) return ERROR; diff --git a/plugins/tests/check_nt.t b/plugins/tests/check_nt.t index d1600c7..223d493 100755 --- a/plugins/tests/check_nt.t +++ b/plugins/tests/check_nt.t @@ -59,7 +59,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") { } if (-x "./check_nt") { - plan tests => 4; + plan tests => 5; } else { plan skip_all => "No check_nt compiled"; } @@ -75,3 +75,6 @@ $result = NPTest->testCmd( "$command -v USEDDISKSPACE -l d" ); 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"); + -- cgit v0.10-9-g596f